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
name: DCO
on:
pull_request:
branches:
merge_group:
workflow_dispatch:
concurrency:
group: dco-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
dco:
name: DCO
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Check DCO sign-off
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.sha }}
run: |
for sha in $(git rev-list "${BASE_SHA}"..HEAD); do
parents=$(git log -1 --format='%P' "$sha")
if [[ "$parents" == *" "* ]]; then
continue
fi
author=$(git log -1 --format='%an' "$sha")
if [[ "$author" == *"[bot]" ]]; then
echo "Skipping bot commit $sha by $author"
continue
fi
if ! git log -1 --format='%B' "$sha" | grep -qi '^Signed-off-by:'; then
echo "::error::Commit $sha by $author is missing Signed-off-by"
exit 1
fi
done
echo "All commits have DCO sign-off"