Skip to content

Commit

Permalink
ci(github): action
Browse files Browse the repository at this point in the history
add github action to verify commit
  • Loading branch information
haloivanid committed Nov 28, 2024
1 parent 6bcebbd commit 55e5940
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/verify-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Verify Commit Signatures

on:
pull_request:
branches:
- master
- develop
push:
branches:
- master
- develop

jobs:
verify-commit-signature:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Important: fetch all history for all branches and tags

- name: Verify commit signatures
run: |
# Check all commits in the push or pull request
unsigned_commits=$(git log --pretty=format:'%H %an %ae' --no-merges | while read -r commit author email; do
# Verify signature for each commit
if ! git verify-commit "$commit" 2>/dev/null; then
echo "Unsigned commit detected: $commit by $author <$email>"
echo "$commit"
fi
done)
# If there are any unsigned commits, fail the workflow
if [ -n "$unsigned_commits" ]; then
echo "Error: The following commits are not signed:"
echo "$unsigned_commits"
exit 1
fi
echo "All commits are properly signed!"

0 comments on commit 55e5940

Please sign in to comment.