Skip to content

Commit 529be2b

Browse files
committed
ign with multiple keys: import three keys at once
1 parent c216a42 commit 529be2b

File tree

1 file changed

+90
-17
lines changed

1 file changed

+90
-17
lines changed

.github/workflows/pack-debian.yml

Lines changed: 90 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,32 @@ on:
3636
type: string
3737

3838
secrets:
39-
GPG_PRIVATE_KEY:
40-
required: true
41-
PASSPHRASE:
42-
required: true
43-
SSH_KEY_TORRENTS:
39+
PRIMARY_KEY:
40+
required: false
41+
PRIMARY_PASS:
42+
required: false
43+
SECONDARY_KEY:
44+
required: false
45+
SECONDARY_PASS:
46+
required: false
47+
TERTIARY_KEY:
4448
required: false
45-
KNOWN_HOSTS_UPLOAD:
49+
TERTIARY_PASS:
4650
required: false
4751

52+
env:
53+
PRIMARY_KEY: ${{ secrets.PRIMARY_KEY }}
54+
PRIMARY_PASS: ${{ secrets.PRIMARY_PASS }}
55+
SECONDARY_KEY: ${{ secrets.SECONDARY_KEY }}
56+
SECONDARY_PASS: ${{ secrets.SECONDARY_PASS }}
57+
TERTIARY_KEY: ${{ secrets.TERTIARY_KEY }}
58+
TERTIARY_PASS: ${{ secrets.TERTIARY_PASS }}
59+
4860
jobs:
4961

5062
prepare:
63+
name: Prepare releases
64+
if: ${{ github.repository_owner == 'Armbian' }}
5165
runs-on: ubuntu-latest
5266
outputs:
5367
matrix: ${{ steps.prep.outputs.matrix }}
@@ -178,23 +192,66 @@ jobs:
178192
path: repository
179193
ref: repository
180194

181-
- name: Import GPG key
182-
id: import_gpg
195+
- name: Import PRIMARY GPG key
196+
id: import_gpg_primary
197+
if: env.PRIMARY_KEY != ''
198+
uses: crazy-max/ghaction-import-gpg@v6
199+
with:
200+
gpg_private_key: ${{ secrets.PRIMARY_KEY }}
201+
passphrase: ${{ secrets.PRIMARY_PASS || '' }}
202+
203+
- name: Import SECONDARY GPG key
204+
id: import_gpg_secondary
205+
if: env.SECONDARY_KEY != ''
206+
uses: crazy-max/ghaction-import-gpg@v6
207+
with:
208+
gpg_private_key: ${{ secrets.SECONDARY_KEY }}
209+
passphrase: ${{ secrets.SECONDARY_PASS || '' }}
210+
211+
- name: Import TERTIARY GPG key
212+
id: import_gpg_tertiary
213+
if: env.TERTIARY_KEY != ''
183214
uses: crazy-max/ghaction-import-gpg@v6
184215
with:
185-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
186-
passphrase: ${{ secrets.PASSPHRASE }}
216+
gpg_private_key: ${{ secrets.TERTIARY_KEY }}
217+
passphrase: ${{ secrets.TERTIARY_PASS || '' }}
218+
219+
- name: Generate GPG_PARAMETERS array
220+
id: build_gpg_parameters
221+
env:
222+
FPR_PRIMARY: ${{ steps.import_gpg_primary.outputs.fingerprint }}
223+
FPR_SECONDARY: ${{ steps.import_gpg_secondary.outputs.fingerprint }}
224+
FPR_TERTIARY: ${{ steps.import_gpg_tertiary.outputs.fingerprint }}
225+
run: |
226+
echo "GPG_PARAMETERS=(--yes --armor)" >> $GITHUB_ENV
227+
228+
if [ -n "$FPR_PRIMARY" ]; then
229+
echo "GPG_PARAMETERS+=( -u $FPR_PRIMARY )" >> $GITHUB_ENV
230+
fi
231+
232+
if [ -n "$FPR_SECONDARY" ]; then
233+
echo "GPG_PARAMETERS+=( -u $FPR_SECONDARY )" >> $GITHUB_ENV
234+
fi
235+
236+
if [ -n "$FPR_TERTIARY" ]; then
237+
echo "GPG_PARAMETERS+=( -u $FPR_TERTIARY )" >> $GITHUB_ENV
238+
fi
239+
240+
- name: Display GPG_PARAMETERS
241+
run: |
242+
echo "$GPG_PARAMETERS"
187243
188244
- name: Configure git identity
189245
working-directory: repository
246+
env:
247+
GPG_TTY: ${{ env.GPG_TTY || '/dev/tty' }}
190248
run: |
191249
192-
echo "Testing signing" | gpg --sign --armor
193-
194-
gpg -K
195-
echo "#"
196-
git config user.name github-actions
197-
git config user.email github-actions@github.com
250+
echo "Available GPG keys:" >> $GITHUB_STEP_SUMMARY
251+
gpg --list-secret-keys --keyid-format LONG >> $GITHUB_STEP_SUMMARY
252+
#cho "data" | gpg --armor --batch --yes --local-user DF00FAF1C577104B50BF1D0093D6889F9F0E78D5 --sign # need password
253+
# echo "data" | gpg --armor --batch --yes --local-user B4A41B81566CC20009232FE45CD410F6B3CBB6BB --sign # need password
254+
#cho "data" | gpg --armor --batch --yes --local-user 8CFA83D13EB2181EEF5843E41EB30FAF236099FE --sign
198255
199256
- name: Deploy packages
200257
run: |
@@ -214,7 +271,6 @@ jobs:
214271
Architectures: amd64 arm64 armhf riscv64
215272
Components: main
216273
Description: Armbian development repo
217-
SignWith: DF00FAF1C577104B50BF1D0093D6889F9F0E78D5
218274
EOD
219275
220276
# Determine a list of binary debs to include in the repo
@@ -242,7 +298,24 @@ jobs:
242298
echo "Repository generated at ${REPO_DIR}/"
243299
fi
244300
301+
echo "Sign repo"
302+
GPG_PARAMETERS=(
303+
"--yes"
304+
"--armor"
305+
"-u" "DF00FAF1C577104B50BF1D0093D6889F9F0E78D5" # Igor Pecovnik (Ljubljana, Slovenia) <igor.pecovnik@gmail.com>
306+
"-u" "8CFA83D13EB2181EEF5843E41EB30FAF236099FE" # Armbian Repository Signing Key (Repository Key) <info@armbian.com>
307+
)
308+
for i in ${REPO_DIR}/dists/*/Release
309+
do
310+
DISTRO_PATH="$(dirname "$i")"
311+
echo $DISTRO_PATH
312+
gpg "${GPG_PARAMETERS[@]}" --clear-sign -o "$DISTRO_PATH/InRelease" "$i"
313+
gpg "${GPG_PARAMETERS[@]}" --detach-sign -o "$DISTRO_PATH/Release.gpg" "$i"
314+
done
315+
245316
cd ${REPO_DIR}
317+
git config user.name "github-actions"
318+
git config user.email "github-actions@github.com"
246319
git add .
247320
git commit -m "Updating repo" || true
248321
git push origin repository || true

0 commit comments

Comments
 (0)