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+ pull_request :
5+ branches :
6+ - " main" # Run on pull requests to the main branch
7+
8+ jobs :
9+ verify-signoff :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout code
14+ uses : actions/checkout@v4
15+
16+ - name : Validate commits
17+ env :
18+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
19+ run : |
20+ # Ensure both commits in the range exist locally
21+ if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
22+ # First push, check all commits
23+ COMMITS=$(git rev-list ${{ github.sha }})
24+ else
25+ # Fetch the commit range
26+ git fetch origin ${{ github.event.before }} --quiet
27+ COMMITS=$(git log --format='%H' ${{ github.event.before }}..${{ github.sha }})
28+ fi
29+
30+ # Check each commit
31+ for COMMIT in $COMMITS; do
32+ MESSAGE=$(git show -s --format='%B' $COMMIT)
33+
34+ # Check for sign-off
35+ if ! echo "$MESSAGE" | grep -q "Signed-off-by:"; then
36+ echo "❌ Commit $COMMIT is missing a 'Signed-off-by:' line."
37+ exit 1
38+ fi
39+ done
40+
41+ echo "✅ All commits are properly signed off."
You can’t perform that action at this time.
0 commit comments