Skip to content

Commit 5fc139b

Browse files
committed
ci: add workflow to check signed commits
1 parent 568b462 commit 5fc139b

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on: # yamllint disable-line rule:truthy
2+
pull_request:
3+
4+
name: Verify signed commits
5+
6+
jobs:
7+
Check-Signatures:
8+
name: Check GPG signatures
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: "Checkout repo"
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
16+
- name: "Verify all PR commits are signed"
17+
run: |
18+
set -euo pipefail
19+
base="${{ github.event.pull_request.base.sha }}"
20+
head="${{ github.event.pull_request.head.sha }}"
21+
unsigned=""
22+
for sha in $(git rev-list "$base".."$head"); do
23+
sig=$(git log --format='%G?' -1 "$sha")
24+
if [ "$sig" != "G" ] && [ "$sig" != "U" ] && [ "$sig" != "E" ]; then
25+
unsigned="$unsigned $sha"
26+
echo "::error::Commit $sha is not GPG signed (signature status: $sig)"
27+
fi
28+
done
29+
if [ -n "$unsigned" ]; then
30+
echo ""
31+
echo "The following commits are not signed:$unsigned"
32+
echo "Please sign your commits with a GPG key."
33+
exit 1
34+
fi
35+
echo "All commits are GPG signed."

0 commit comments

Comments
 (0)