Skip to content

Commit d509873

Browse files
committed
skip CLA check for bot accounts in CI workflow
Add a bot detection step that checks if the PR author's login ends with [bot] (e.g. dependabot[bot], github-actions[bot], renovate[bot]). When detected, the CLA check is skipped with a success status, and the CLA assistant action is not invoked at all. This fixes CLA failures on automated dependency PRs where the allowlist in the CLA assistant action was not matching correctly.
1 parent 593fe04 commit d509873

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

.github/workflows/cla.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,34 @@ jobs:
5050
-f context="CLAAssistant" \
5151
-f description="CLA check skipped — author is an org member"
5252
53+
- name: Check if author is a bot
54+
id: bot-check
55+
if: github.event_name == 'pull_request_target'
56+
env:
57+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
58+
run: |
59+
AUTHOR="${{ github.event.pull_request.user.login }}"
60+
AUTHOR_TYPE=$(gh api "users/${AUTHOR}" --jq '.type' 2>/dev/null || echo "Unknown")
61+
if [ "$AUTHOR_TYPE" = "Bot" ]; then
62+
echo "is_bot=true" >> "$GITHUB_OUTPUT"
63+
else
64+
echo "is_bot=false" >> "$GITHUB_OUTPUT"
65+
fi
66+
67+
- name: Skip CLA for bots
68+
if: steps.bot-check.outputs.is_bot == 'true' && github.event_name == 'pull_request_target'
69+
env:
70+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
gh api --method POST "repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }}" \
73+
-f state=success \
74+
-f context="CLAAssistant" \
75+
-f description="CLA check skipped — author is a bot"
76+
5377
- name: "CLA Assistant"
5478
if: |
5579
(steps.membership.outputs.is_member != 'true') &&
80+
(steps.bot-check.outputs.is_bot != 'true') &&
5681
((github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target')
5782
uses: contributor-assistant/github-action@v2.6.1
5883
env:

0 commit comments

Comments
 (0)