Skip to content

Commit aa1e246

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

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

.github/workflows/build.yml

Lines changed: 33 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,16 @@ 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+
102+
echo "Sign repo with multiple keys"
103+
for i in debian/artifacts/dists/*/Release
104+
do
105+
DISTRO_PATH="$(dirname "$i")"
106+
echo $DISTRO_PATH
107+
gpg ${{ env.GPG_PARAMETERS }} --clear-sign -o "$DISTRO_PATH/InRelease" "$i"
108+
gpg ${{ env.GPG_PARAMETERS }} --detach-sign -o "$DISTRO_PATH/Release.gpg" "$i"
109+
done
110+
82111
git add debian/artifacts/{pool,dists}
83112
git diff --cached --quiet || git commit --allow-empty -m "Update published repository files"
84113
git push --force --set-upstream origin data

0 commit comments

Comments
 (0)