Skip to content

Commit e056275

Browse files
Replace third-party DCO action with custom script (#769)
The tisonkun/actions-dco action has been unreliable. Replace it with an inline bash script (matching databricks-sql-go) that checks each commit for a Signed-off-by line, provides clear per-commit feedback, and scopes the trigger to opened/synchronize/reopened events on main. Co-authored-by: Isaac Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
1 parent 4793353 commit e056275

File tree

1 file changed

+62
-19
lines changed

1 file changed

+62
-19
lines changed

.github/workflows/dco-check.yml

Lines changed: 62 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,72 @@
11
name: DCO Check
22

3-
on: [pull_request]
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
branches: [main]
47

58
permissions:
69
contents: read
7-
pull-requests: write
810

911
jobs:
10-
check:
12+
dco-check:
1113
runs-on: ubuntu-latest
14+
name: Check DCO Sign-off
1215
steps:
13-
- name: Check for DCO
14-
id: dco-check
15-
uses: tisonkun/actions-dco@6d1f8a197db1b04df1769707b46b9366b1eca902 # v1.1
16-
- name: Comment about DCO status
17-
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
18-
if: ${{ failure() }}
16+
- name: Checkout
17+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
1918
with:
20-
script: |
21-
github.rest.issues.createComment({
22-
issue_number: context.issue.number,
23-
owner: context.repo.owner,
24-
repo: context.repo.repo,
25-
body: `Thanks for your contribution! To satisfy the DCO policy in our \
26-
[contributing guide](https://github.com/databricks/databricks-sql-python/blob/main/CONTRIBUTING.md) \
27-
every commit message must include a sign-off message. One or more of your commits is missing this message. \
28-
You can reword previous commit messages with an interactive rebase (\`git rebase -i main\`).`
29-
})
19+
fetch-depth: 0
20+
21+
- name: Check DCO Sign-off
22+
env:
23+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
24+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
25+
run: |
26+
#!/bin/bash
27+
set -e
28+
29+
echo "Checking commits from $BASE_SHA to $HEAD_SHA"
30+
31+
COMMITS=$(git rev-list --no-merges "$BASE_SHA..$HEAD_SHA")
32+
33+
if [ -z "$COMMITS" ]; then
34+
echo "No commits found in this PR"
35+
exit 0
36+
fi
37+
38+
FAILED_COMMITS=()
39+
40+
for commit in $COMMITS; do
41+
echo "Checking commit: $commit"
42+
COMMIT_MSG=$(git log --format=%B -n 1 "$commit")
43+
if echo "$COMMIT_MSG" | grep -q "^Signed-off-by: "; then
44+
echo " Commit $commit has DCO sign-off"
45+
else
46+
echo " Commit $commit is missing DCO sign-off"
47+
FAILED_COMMITS+=("$commit")
48+
fi
49+
done
50+
51+
if [ ${#FAILED_COMMITS[@]} -ne 0 ]; then
52+
echo ""
53+
echo "DCO Check Failed!"
54+
echo "The following commits are missing the required 'Signed-off-by' line:"
55+
for commit in "${FAILED_COMMITS[@]}"; do
56+
echo " - $commit: $(git log --format=%s -n 1 "$commit")"
57+
done
58+
echo ""
59+
echo "To fix this, you need to sign off your commits. You can:"
60+
echo "1. Add sign-off to new commits: git commit -s -m 'Your commit message'"
61+
echo "2. Amend existing commits: git commit --amend --signoff"
62+
echo "3. For multiple commits, use: git rebase --signoff HEAD~N (where N is the number of commits)"
63+
echo ""
64+
echo "The sign-off should be in the format:"
65+
echo "Signed-off-by: Your Name <your.email@example.com>"
66+
echo ""
67+
echo "For more details, see CONTRIBUTING.md"
68+
exit 1
69+
else
70+
echo ""
71+
echo "All commits have proper DCO sign-off!"
72+
fi

0 commit comments

Comments
 (0)