File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments