Skip to content

Commit

Permalink
Merge pull request hashicorp#1 from hashicorp/add-gpg
Browse files Browse the repository at this point in the history
add gpg private key importing
  • Loading branch information
alvin-huang authored May 6, 2021
2 parents 442145c + 6879be0 commit ffbabfe
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
# ghaction-import-gpg
GitHub action to import GPG private key

**Note [5/6/2021]:** This was supposed to be a fork ([paultyng/ghaction-import-gpg](https://github.com/paultyng/ghaction-import-gpg)) of a fork ([crazy-max/ghaction-import-gpg](https://github.com/crazy-max/ghaction-import-gpg)) of the upstream repo. Due to the restrictions on using a sign-only key, we encountered this [issue](https://github.com/crazy-max/ghaction-import-gpg/issues/58). This is an internal action that overrides this fork until the issue is resolved upstream.
## Environment Variables

Following environment variables must be used as `step.env` keys

| Name | Description |
|--------------------|---------------------------------------|
| `GPG_PRIVATE_KEY` | GPG private key exported as an ASCII armored version (**required**) |
| `PASSPHRASE` | Passphrase of the `GPG_PRIVATE_KEY` key if set |

## Workflow Example

```yaml
name: sign
on: push

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Import GPG key
id: import_gpg
uses: hashicorp/[email protected]
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- run: |
touch foo.txt
gpg --detach-sig foo.txt
```
14 changes: 14 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# action.yml
name: "GPG key import"
description: "Import private GPG key"
runs:
using: "composite"
steps:
- run: |
#
echo -e "${{ env.GPG_PRIVATE_KEY }}" | gpg --import --batch --no-tty
echo "hello world" > temp.txt
gpg --detach-sig --yes -v --output=/dev/null --pinentry-mode loopback --passphrase "${{ env.PASSPHRASE }}" temp.txt
rm temp.txt
shell: bash
name: import GPG key and prime passphrase

0 comments on commit ffbabfe

Please sign in to comment.