forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (61 loc) · 2.54 KB
/
Copy pathdco-check.yml
File metadata and controls
66 lines (61 loc) · 2.54 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
name: DCO Check
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
checks: write
jobs:
dco:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: DCO Check — require Signed-off-by on all commits
shell: bash
run: |
set +e
bad=0
for commit in $(git log --format='%H' origin/${{ github.base_ref }}..HEAD 2>/dev/null || git log --format='%H' HEAD~${{ github.event.pull_request.commits }}..HEAD); do
msg=$(git log --format='%B' -1 "$commit")
if ! echo "$msg" | grep -qi 'Signed-off-by:'; then
echo "❌ Commit $commit is missing Signed-off-by:"
echo " $(git log --format='%s' -1 "$commit")"
bad=$((bad + 1))
fi
done
if [ "$bad" -gt 0 ]; then
echo ""
echo "⚠️ All commits must include a Signed-off-by line."
echo " Fix: git commit --amend --signoff (for latest commit)"
echo " Or: git rebase --signoff HEAD~N (for N commits)"
exit 1
fi
echo "✅ All commits have Signed-off-by."
- name: Post DCO status on PR
if: always()
uses: actions/github-script@v7
with:
script: |
const dcoPass = '${{ job.status }}' === 'success';
const body = dcoPass
? '✅ **DCO Check Passed** — All commits include `Signed-off-by:`. Thank you for respecting code origin!'
: '❌ **DCO Check Failed** — Some commits are missing `Signed-off-by:`. Please amend with `--signoff`.';
const conclusion = dcoPass ? 'success' : 'action_required';
await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'DCO / Signed-off-by',
head_sha: context.payload.pull_request.head.sha,
status: 'completed',
conclusion: conclusion,
output: {
title: 'Developer Certificate of Origin',
summary: body,
text: dcoPass
? 'All commits include a Signed-off-by trailer. This certifies that the contributor has the right to submit the code under the project license.'
: 'One or more commits are missing the Signed-off-by trailer. Use `git commit --amend --signoff` or `git rebase --signoff` to fix.'
}
});