Skip to content

Commit d4cd952

Browse files
committed
[#2] Fix passing env vars
1 parent 2d2f4e0 commit d4cd952

File tree

4 files changed

+15
-34
lines changed

4 files changed

+15
-34
lines changed

.env.template

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
22
INPUT_REPO_TOKEN=XX
3-
INPUT_PASSPHRASE=XX
4-
INPUT_KEYGRIP=XX
5-
INPUT_GPG_PRIVATE_KEY=-----BEGIN PGP PRIVATE KEY BLOCK-----\n\nlXX\n-----END PGP PRIVATE KEY BLOCK-----\n
3+
GPG_PRIVATE_KEY=-----BEGIN PGP PRIVATE KEY BLOCK-----\n\nlXX\n-----END PGP PRIVATE KEY BLOCK-----\n
4+
PASSPHRASE=XX

.github/workflows/example-03.yml

+6-24
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,15 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v2
1212

13-
- name: Import GPG key
14-
id: import-gpg
15-
uses: crazy-max/ghaction-import-gpg@v4
16-
with:
17-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
18-
passphrase: ${{ secrets.PASSPHRASE }}
19-
git_user_signingkey: true
20-
git_commit_gpgsign: true
21-
22-
- name: GPG user IDs
23-
run: |
24-
echo "fingerprint: ${{ steps.import-gpg.outputs.fingerprint }}"
25-
echo "keyid: ${{ steps.import-gpg.outputs.keyid }}"
26-
echo "name: ${{ steps.import-gpg.outputs.name }}"
27-
echo "email: ${{ steps.import-gpg.outputs.email }}"
28-
2913
- name: Build docker image
3014
run: ./bin/build.sh
3115

3216
- name: Run example 03
3317
run: |
3418
docker run --rm \
35-
--volume $(pwd):/app \
36-
pygithub src/03_sign_commit_using_the_gitpython_package.py
37-
git push
38-
env:
39-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
40-
PASSPHRASE: ${{ secrets.PASSPHRASE }}
41-
MODE: "workflow"
42-
REPO_DIR: "${{ github.workspace }}"
19+
--env GPG_PRIVATE_KEY="${{ secrets.GPG_PRIVATE_KEY }}" \
20+
--env PASSPHRASE="${{ secrets.PASSPHRASE }}" \
21+
--env MODE="workflow" \
22+
--env REPO_DIR="/app" \
23+
--volume "$(pwd):/app" \
24+
pygithub src/03_sign_commit_using_the_gitpython_package.py

bin/run-03.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
docker run --rm -it \
44
--env-file .env \
5-
--env INPUT_MODE=test \
6-
--env INPUT_REPO_DIR=/app \
7-
--volume $(pwd):/app \
5+
--env MODE=test \
6+
--env REPO_DIR=/app \
7+
--volume "$(pwd):/app" \
88
pygithub src/03_sign_commit_using_the_gitpython_package.py

src/03_sign_commit_using_the_gitpython_package.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ def main(gpg_private_key, passphrase, repo_dir):
227227
# https://gitpython.readthedocs.io/
228228

229229
# Get environment variables
230-
gpg_private_key = os.getenv('INPUT_GPG_PRIVATE_KEY').replace(r'\n', '\n')
231-
passphrase = os.environ.get('INPUT_PASSPHRASE')
232-
mode = os.environ.get('INPUT_MODE')
233-
repo_dir = os.environ.get('INPUT_REPO_DIR')
230+
gpg_private_key = os.getenv('GPG_PRIVATE_KEY').replace(r'\n', '\n')
231+
passphrase = os.environ.get('PASSPHRASE')
232+
mode = os.environ.get('MODE')
233+
repo_dir = os.environ.get('REPO_DIR')
234234

235235
if (mode == 'test'):
236236
# Create temp dir for the example

0 commit comments

Comments
 (0)