Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
- name: Check last git commit signature against trusted keys
run: bash -x ./test/check-last-commit-signature-key.sh
22 changes: 22 additions & 0 deletions test/check-last-commit-signature-key.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
# check that last git commit is signed and signer's key is present in keys directory

cd "$(dirname "$0")" || exit 1

last_commit_key_id="$(git log --no-merges --show-signature | grep -E "using [A-Za-z0-9]+ key" | head -n 1 | tail -c 17)"

if [ -z "$last_commit_key_id" ]; then
echo "Last commit is not signed"
exit 1
fi

for keyfile in ../keys/*.asc; do
keyid="$(gpg --with-colons "$keyfile" 2>/dev/null | grep '^pub' | cut -d: -f5)"
if [ "$keyid" = "$last_commit_key_id" ]; then
echo "Last commit is signed with a known key: $last_commit_key_id"
exit 0
fi
done

echo "Last commit is signed with an unknown key: $last_commit_key_id"
exit 1