-
Notifications
You must be signed in to change notification settings - Fork 60
72 lines (62 loc) · 2.28 KB
/
dco-check.yml
File metadata and controls
72 lines (62 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: DCO Check
on:
pull_request:
types: [opened, synchronize, reopened]
branches: [main]
permissions:
contents: read
jobs:
dco-check:
runs-on: ubuntu-latest
name: Check DCO Sign-off
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: Check DCO Sign-off
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
#!/bin/bash
set -e
echo "Checking commits from $BASE_SHA to $HEAD_SHA"
COMMITS=$(git rev-list --no-merges "$BASE_SHA..$HEAD_SHA")
if [ -z "$COMMITS" ]; then
echo "No commits found in this PR"
exit 0
fi
FAILED_COMMITS=()
for commit in $COMMITS; do
echo "Checking commit: $commit"
COMMIT_MSG=$(git log --format=%B -n 1 "$commit")
if echo "$COMMIT_MSG" | grep -q "^Signed-off-by: "; then
echo " Commit $commit has DCO sign-off"
else
echo " Commit $commit is missing DCO sign-off"
FAILED_COMMITS+=("$commit")
fi
done
if [ ${#FAILED_COMMITS[@]} -ne 0 ]; then
echo ""
echo "DCO Check Failed!"
echo "The following commits are missing the required 'Signed-off-by' line:"
for commit in "${FAILED_COMMITS[@]}"; do
echo " - $commit: $(git log --format=%s -n 1 "$commit")"
done
echo ""
echo "To fix this, you need to sign off your commits. You can:"
echo "1. Add sign-off to new commits: git commit -s -m 'Your commit message'"
echo "2. Amend existing commits: git commit --amend --signoff"
echo "3. For multiple commits, use: git rebase --signoff HEAD~N (where N is the number of commits)"
echo ""
echo "The sign-off should be in the format:"
echo "Signed-off-by: Your Name <your.email@example.com>"
echo ""
echo "For more details, see CONTRIBUTING.md"
exit 1
else
echo ""
echo "All commits have proper DCO sign-off!"
fi