Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/dco.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: DCO

# Every commit in a pull request must carry a Developer Certificate of Origin sign-off
# (`Signed-off-by: Name <email>`, added by `git commit -s`) whose email is the commit
# author's. CONTRIBUTING.md explains why (see "Licensing of your contribution").
# Merge commits and bot commits (Dependabot) are exempt.

on:
pull_request:

permissions:
contents: read

jobs:
dco:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Every commit is signed off by its author
env:
BASE: ${{ github.event.pull_request.base.sha }}
HEAD: ${{ github.event.pull_request.head.sha }}
run: |
missing=0
for c in $(git rev-list --no-merges "$BASE..$HEAD"); do
email=$(git log -1 --format=%ae "$c")
case "$email" in
*'[bot]@users.noreply.github.com') continue ;;
Comment on lines +30 to +31

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify bot provenance before exempting unsigned commits

A human contributor can bypass the sign-off requirement by setting a commit's author email to dependabot[bot]@users.noreply.github.com: this branch skips the commit without checking whether a bot actually created it. Author metadata is contributor-controlled (git commit -h documents --author as “override author for commit”), so the email suffix does not establish bot provenance. Base the exemption on trusted bot provenance, or require sign-offs for these commits as well, to prevent unsigned human contributions from passing the DCO check.

Useful? React with 👍 / 👎.

esac
if ! git log -1 --format=%B "$c" | grep -i '^Signed-off-by:' | grep -qiF "<$email>"; then
echo "::error::$(git log -1 --format='%h %s' "$c"): no 'Signed-off-by: ... <$email>' line"
missing=1
fi
done
if [ "$missing" = 1 ]; then
echo "Sign off your commits: 'git commit -s' for new ones, 'git rebase --signoff $BASE' for these, then force-push."
exit 1
fi
echo "All commits are signed off."
Loading