Skip to content

Commit d66793b

Browse files
committed
APA: sign with multiple keys at once
1 parent 9be6552 commit d66793b

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

.github/workflows/build.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ jobs:
4747
if-no-files-found: ignore
4848

4949
merge:
50+
env:
51+
PRIMARY_KEY: ${{ secrets.GPG_KEY3 }}
52+
SECONDARY_KEY: ${{ secrets.GPG_KEY4 }}
5053
name: "Merge artifacts and publish"
5154
needs: build-debs
5255
runs-on: ubuntu-latest
@@ -65,12 +68,28 @@ jobs:
6568
run: |
6669
sudo apt-get update
6770
sudo apt-get install -y reprepro
68-
- name: Import GPG key
69-
id: import_gpg
71+
- name: Import PRIMARY GPG key
72+
id: import_gpg_primary
73+
if: env.PRIMARY_KEY != ''
7074
uses: crazy-max/ghaction-import-gpg@v6
7175
with:
72-
gpg_private_key: ${{ secrets.GPG_KEY1 }}
73-
passphrase: ${{ secrets.GPG_PASSPHRASE1 }}
76+
gpg_private_key: ${{ env.PRIMARY_KEY }}
77+
- name: Import SECONDARY GPG key
78+
id: import_gpg_secondary
79+
if: env.SECONDARY_KEY != ''
80+
uses: crazy-max/ghaction-import-gpg@v6
81+
with:
82+
gpg_private_key: ${{ env.SECONDARY_KEY }}
83+
- name: Generate GPG_PARAMETERS array
84+
id: build_gpg_parameters
85+
env:
86+
FPR_PRIMARY: ${{ steps.import_gpg_primary.outputs.fingerprint }}
87+
FPR_SECONDARY: ${{ steps.import_gpg_secondary.outputs.fingerprint }}
88+
run: |
89+
GPG_PARAMETERS="--yes --armor"
90+
[ -n "$FPR_PRIMARY" ] && GPG_PARAMETERS+=" -u $FPR_PRIMARY"
91+
[ -n "$FPR_SECONDARY" ] && GPG_PARAMETERS+=" -u $FPR_SECONDARY"
92+
echo "GPG_PARAMETERS=$GPG_PARAMETERS" >> "$GITHUB_ENV"
7493
- name: Create distribution repository and commit to data branch
7594
run: |
7695
git checkout --orphan data
@@ -79,6 +98,14 @@ jobs:
7998
git config --global user.email "[email protected]"
8099
for file in debian/artifacts/*.changes; do reprepro -b debian/artifacts include current $file;done
81100
reprepro -b debian/artifacts export
101+
echo "Sign repo with multiple keys"
102+
find "debian/artifacts/dists" -type f -name Release | while read -r release_file; do
103+
local distro_path
104+
distro_path="$(dirname "$release_file")"
105+
echo "Signing release at: $distro_path"
106+
gpg ${{ env.GPG_PARAMETERS }} --clear-sign -o "$distro_path/InRelease" "$release_file"
107+
gpg ${{ env.GPG_PARAMETERS }} --detach-sign -o "$distro_path/Release.gpg" "$release_file"
108+
done
82109
git add debian/artifacts/{pool,dists}
83110
git diff --cached --quiet || git commit --allow-empty -m "Update published repository files"
84111
git push --force --set-upstream origin data

0 commit comments

Comments
 (0)