Skip to content

Commit 7e7eccf

Browse files
committed
actions: add action to validate signature
Signed-off-by: Piyush Jena <[email protected]>
1 parent 2f694d9 commit 7e7eccf

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Enforce Signed Commits
2+
3+
on:
4+
pull_request:
5+
branches: [develop]
6+
7+
jobs:
8+
check_signed_commits:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Get the SHA before the first commit
15+
id: first_commit_parent
16+
run: |
17+
BASE_SHA="${{ github.event.head.sha }}"
18+
HEAD_SHA="${{ github.sha }}"
19+
PARENT_SHA=$(git merge-base $BASE_SHA $HEAD_SHA)
20+
echo "The SHA before the first commit in this branch is: $PARENT_SHA"
21+
echo "parent_sha=$PARENT_SHA" >> $GITHUB_OUTPUT
22+
23+
- name: Verify all commits in push are signed
24+
run: |
25+
git log ${{ steps.first_commit_parent.outputs.parent_sha }}..${{ github.sha }} --pretty="%H %G?" --no-merges | while read commit_hash signature_status; do
26+
if [ "$signature_status" != "U" ]; then
27+
echo "Error: Unsigned commit found: $commit_hash"
28+
exit 1
29+
fi
30+
done

0 commit comments

Comments
 (0)