File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Verify Commit Signoff
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+ branches :
9+ - ' *'
10+ workflow_dispatch :
11+
12+ jobs :
13+ verify-signoff :
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ - name : Checkout code
18+ uses : actions/checkout@v4
19+ with :
20+ fetch-depth : 0 # Ensure full history is available
21+
22+ - name : Validate commits
23+ env :
24+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
25+ run : |
26+ # Get commit range dynamically
27+ if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
28+ # First push or forced update; check all commits
29+ COMMITS=$(git rev-list HEAD)
30+ else
31+ # Use HEAD for latest commit and github.event.before for range
32+ git fetch origin ${{ github.event.before }} --quiet
33+ COMMITS=$(git log --format='%H' remotes/origin/${{ github.head_ref }})
34+ fi
35+
36+ # Validate each commit
37+ for COMMIT in $COMMITS; do
38+ MESSAGE=$(git show -s --format='%B' $COMMIT)
39+
40+ # Check for sign-off
41+ if ! echo "$MESSAGE" | grep -q "Signed-off-by:"; then
42+ echo "❌ Commit $COMMIT is missing a 'Signed-off-by:' line."
43+ exit 1
44+ fi
45+ done
46+
47+ echo "✅ All commits are properly signed off."
You can’t perform that action at this time.
0 commit comments