Skip to content

Commit ac3182d

Browse files
committed
Test GPG key expiry.
1 parent a129fa4 commit ac3182d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

.github/workflows/key.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test GPG Key Expiry
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '30 3 * * *'
7+
8+
jobs:
9+
key-expiry:
10+
name: Test GPG Key Expiry
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Import GPG key
14+
uses: crazy-max/ghaction-import-gpg@v6
15+
with:
16+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
17+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
18+
- name: Test GPG key expiry
19+
run: |
20+
EXPIRY=$(gpg --list-keys | egrep -o "expires:\s+[0-9-]+" | egrep -o "[0-9-]+" | sort | head -n 1)
21+
echo "GPG key expires on ${EXPIRY}"
22+
DELTA=$(( $(date --date "${EXPIRY}" '+%s') - $(date '+%s') ))
23+
echo "GPG key expires in ${DELTA} seconds"
24+
[[ ${DELTA} -ge 2592000 ]] && echo "GPG key valid for at least another 30 days" || echo "GPG key will expire within the next 30 days"
25+
[[ ${DELTA} -ge 2592000 ]]

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ jobs:
2323
with:
2424
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
2525
passphrase: ${{ secrets.GPG_PASSPHRASE }}
26+
- name: Test GPG key expiry
27+
run: |
28+
EXPIRY=$(gpg --list-keys | egrep -o "expires:\s+[0-9-]+" | egrep -o "[0-9-]+" | sort | head -n 1)
29+
echo "GPG key expires on ${EXPIRY}"
30+
DELTA=$(( $(date --date "${EXPIRY}" '+%s') - $(date '+%s') ))
31+
echo "GPG key expires in ${DELTA} seconds"
32+
[[ ${DELTA} -ge 0 ]]
2633
- name: Set up JDK/Maven
2734
uses: actions/setup-java@v4
2835
with:

0 commit comments

Comments
 (0)