-
Notifications
You must be signed in to change notification settings - Fork 0
Fix cla-check.yml to correctly handle multi-author PRs end-to-end #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
256565d
0154711
11df4f9
0741c5c
6f26b1e
ca3a5eb
28581c1
304069a
53e4fd6
c7a6412
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -58,6 +58,7 @@ jobs: | |||||||||||||||||||||
| should_run_cla: ${{ steps.check-membership.outputs.should_run_cla }} | ||||||||||||||||||||||
| exempt_users: ${{ steps.check-membership.outputs.exempt_users }} | ||||||||||||||||||||||
| exempt_users_csv: ${{ steps.check-membership.outputs.exempt_users_csv }} | ||||||||||||||||||||||
| needs_cla_csv: ${{ steps.check-membership.outputs.needs_cla_csv }} | ||||||||||||||||||||||
| steps: | ||||||||||||||||||||||
| - name: Debug Event Context | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
|
|
@@ -221,6 +222,14 @@ jobs: | |||||||||||||||||||||
| fi | ||||||||||||||||||||||
| echo "exempt_users_csv=$EXEMPT_USERNAMES_CSV" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Output users who need CLA as comma-separated string | ||||||||||||||||||||||
| if [ ${#NEEDS_CLA[@]} -eq 0 ]; then | ||||||||||||||||||||||
| NEEDS_CLA_CSV="" | ||||||||||||||||||||||
| else | ||||||||||||||||||||||
| NEEDS_CLA_CSV="$(IFS=','; echo "${NEEDS_CLA[*]}")" | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| echo "needs_cla_csv=$NEEDS_CLA_CSV" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if [ ${#NEEDS_CLA[@]} -eq 0 ]; then | ||||||||||||||||||||||
| echo "All committers are org members or allowed bots; CLA not required" | ||||||||||||||||||||||
| echo "is_member=true" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||
|
|
@@ -307,6 +316,89 @@ jobs: | |||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - name: Post Multi-Author CLA Comment | ||||||||||||||||||||||
| uses: actions/github-script@v7 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||
| script: | | ||||||||||||||||||||||
|
Comment on lines
+333
to
+337
|
||||||||||||||||||||||
| // Only run for pull_request_target events or issue_comment events on PRs | ||||||||||||||||||||||
| if (context.eventName === 'issue_comment' && !context.payload.issue?.pull_request) { | ||||||||||||||||||||||
| console.log('issue_comment is on a regular issue (not a PR), skipping'); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| if (context.eventName !== 'pull_request_target' && context.eventName !== 'issue_comment') { | ||||||||||||||||||||||
| console.log(`Event ${context.eventName} not applicable for CLA comment, skipping`); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const needsCsvRaw = '${{ needs.check-cla.outputs.needs_cla_csv }}'; | ||||||||||||||||||||||
| if (!needsCsvRaw) { | ||||||||||||||||||||||
| console.log('No users need CLA, skipping comment'); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const users = needsCsvRaw.split(',').map(u => u.trim()).filter(Boolean); | ||||||||||||||||||||||
| if (users.length === 0) { | ||||||||||||||||||||||
| console.log('No users need CLA, skipping comment'); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const prNumber = context.payload.pull_request?.number || context.payload.issue?.number; | ||||||||||||||||||||||
| if (!prNumber) { | ||||||||||||||||||||||
| console.log('No PR number found, skipping comment'); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const repoName = '${{ inputs.repo_name }}'; | ||||||||||||||||||||||
| const claUrl = '${{ steps.cla-url.outputs.url }}'; | ||||||||||||||||||||||
| const mentions = users.map(u => `@${u}`).join(', '); | ||||||||||||||||||||||
| const MARKER = '<!-- cla-multi-author-check -->'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const body = `${MARKER} | ||||||||||||||||||||||
| 👋 Hey ${mentions}, | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## Thanks for your contribution to \`${repoName}\`! 🧵 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
||||||||||||||||||||||
| ### You need to agree to the CLA first... 🖊️ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Before we can accept your contribution, **you (each of you) need to agree to our Contributor License Agreement (CLA)**. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ### To agree to the CLA, please comment: | ||||||||||||||||||||||
|
||||||||||||||||||||||
| ### You need to agree to the CLA first... 🖊️ | |
| Before we can accept your contribution, **you (each of you) need to agree to our Contributor License Agreement (CLA)**. | |
| ### To agree to the CLA, please comment: | |
| ### If you haven't already agreed to the CLA... 🖊️ | |
| Before we can accept your contribution, **please make sure you have agreed to our Contributor License Agreement (CLA)**. If you have already signed it, no further action is needed. | |
| ### If you still need to agree to the CLA, please comment: |
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
github.rest.issues.listComments is called without pagination (per_page) or github.paginate, so only the first page of comments is searched for the marker. If a PR has many comments, the existing marker comment may not be found and a duplicate comment will be created. Consider using github.paginate(github.rest.issues.listComments, { ... , per_page: 100 }) (or manual pagination) before searching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs_cla_csvis built directly from theNEEDS_CLAarray, which can contain the sentinel value"<unknown>"(added earlier when a commit has no linked GitHub login). This will propagate into downstream mentions (e.g.,@<unknown>) and into the CLA Assistant comment template. Consider filtering out non-mentionable placeholders (or mapping them to something non-@mention) before writingneeds_cla_csvto$GITHUB_OUTPUT.