| 1 |
name: DCO Check |
| 2 |
|
| 3 |
on: |
| 4 |
pull_request: |
| 5 |
types: [opened, synchronize, reopened, ready_for_review] |
| 6 |
|
| 7 |
concurrency: |
| 8 |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 9 |
cancel-in-progress: true |
| 10 |
|
| 11 |
jobs: |
| 12 |
check: |
| 13 |
if: ${{ !github.event.pull_request.draft }} |
| 14 |
runs-on: ubuntu-latest |
| 15 |
steps: |
| 16 |
- name: Checkout commit logs |
| 17 |
run: | |
| 18 |
git init |
| 19 |
git fetch --filter=blob:none "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" "$GITHUB_BASE_REF" "$GITHUB_REF" |
| 20 |
- name: Check for DCO sign-offs |
| 21 |
shell: bash |
| 22 |
run: | |
| 23 |
status=0 |
| 24 |
while read -r commit; do |
| 25 |
author="$(git show --no-patch --pretty='format:%an <%ae>' "$commit")" |
| 26 |
if ! git show --no-patch --pretty='format:%(trailers:key=Signed-off-by,valueonly)' "$commit" | grep -Fxq "$author"; then |
| 27 |
if [ $status -eq 0 ]; then |
| 28 |
echo "The following commits are missing a Developer Certificate of Origin sign-off;" |
| 29 |
echo "see https://github.com/osandov/drgn/blob/main/CONTRIBUTING.rst#signing-off" |
| 30 |
echo |
| 31 |
fi |
| 32 |
status=1 |
| 33 |
git show --no-patch "$commit" |
| 34 |
fi |
| 35 |
done < <(git rev-list --no-merges "FETCH_HEAD..$GITHUB_SHA") |
| 36 |
if [ $status -eq 0 ]; then |
| 37 |
echo "All commits have a Developer Certificate of Origin sign-off" |
| 38 |
fi |
| 39 |
exit $status |