Skip to content

cla-file-check GitHub action - check before again and again posting about the CLA that needs signing by the contributor.#168

Merged
lukehalasy-anchorage merged 4 commits intomainfrom
fix/cla-duplicate-comments
Feb 7, 2026
Merged

cla-file-check GitHub action - check before again and again posting about the CLA that needs signing by the contributor.#168
lukehalasy-anchorage merged 4 commits intomainfrom
fix/cla-duplicate-comments

Conversation

@lukehalasy-anchorage
Copy link
Contributor

@lukehalasy-anchorage lukehalasy-anchorage commented Feb 6, 2026

Previously, the CLA workflow would post a comment asking the user to sign the CLA on every commit pushed to a PR. This created noise and made PR reviewing harder.

Now the workflow checks if a CLA comment already exists before posting, ensuring users only get notified once per PR.
above to be verified post-merge via opening a PR via my other GitHub account
testing of the bash within the new step orchestrated here -> https://github.com/anchorageoss/visualsign-parser/pull/168/changes#r2772045200

Fixes #54

🤖 Generated with Claude Code

@lukehalasy-anchorage lukehalasy-anchorage changed the title cla-file-check GitHub action - check before again and again about the CLA that needs signing by the contributor. cla-file-check GitHub action - check before again and again posting about the CLA that needs signing by the contributor. Feb 6, 2026
@lukehalasy-anchorage lukehalasy-anchorage marked this pull request as ready for review February 6, 2026 02:45
Copilot AI review requested due to automatic review settings February 6, 2026 02:45
@lukehalasy-anchorage
Copy link
Contributor Author

lukehalasy-anchorage commented Feb 6, 2026

we can test at least the command within this.

gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions[bot]") | .body' | grep -q "Contributor License Agreement"

the script, ( supposedly), if this is true will skip.
we can run this against a PR that has such a CLA comment like #162

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request addresses issue #54 by preventing the CLA workflow from posting duplicate comments on every commit to a pull request. The workflow now checks if a CLA-related comment from the github-actions bot already exists before posting a new one.

Changes:

  • Added a new step to check for existing CLA comments from the github-actions bot
  • Modified the comment posting step to only execute when no existing CLA comment is found
  • Reduced notification noise for contributors who haven't signed the CLA

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

id: check_comment
run: |
# Check if github-actions bot has already commented about CLA on this PR
if gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions[bot]") | .body' | grep -q "Contributor License Agreement"; then
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

This command pipeline will fail if no comments from github-actions bot exist yet, because grep returns a non-zero exit code when it finds no matches. This would prevent the workflow from ever posting the first CLA comment. Add error handling by appending || true to the end of the pipeline, or restructure to explicitly handle the exit code. For example: if gh pr view ... | grep -q "..." 2>/dev/null; then or wrap the entire condition in a way that handles the failure case.

Suggested change
if gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions[bot]") | .body' | grep -q "Contributor License Agreement"; then
COMMENTS=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions[bot]") | .body' || true)
if echo "$COMMENTS" | grep -q "Contributor License Agreement"; then

Copilot uses AI. Check for mistakes.
@lukehalasy-anchorage lukehalasy-anchorage marked this pull request as draft February 6, 2026 02:51
@lukehalasy-anchorage lukehalasy-anchorage changed the title cla-file-check GitHub action - check before again and again posting about the CLA that needs signing by the contributor. [draft] cla-file-check GitHub action - check before again and again posting about the CLA that needs signing by the contributor. Feb 6, 2026
else
echo "No CLA comment found, will post one"
echo "comment_exists=false" >> $GITHUB_OUTPUT
fi
Copy link
Contributor Author

@lukehalasy-anchorage lukehalasy-anchorage Feb 6, 2026

Choose a reason for hiding this comment

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

here's a simple test I ran for this ( copied this into a bash script with configurable pr passed in )

[03:06:26] /home/user/visualsign-parser (fix/cla-duplicate-comments=)
\─<")>< cat test.sh
#!/bin/bash

COMMENTS=$(gh pr view $PR_NUMBER --json comments --jq '.comments[] | select(.author.login == "github-actions") | .body')

if echo "$COMMENTS" | grep -q "Contributor License Agreement"; then
  echo "CLA comment already exists, skipping"
  echo "comment_exists=true" >> $GITHUB_OUTPUT
else
  echo "No CLA comment found, will post one"
  echo "comment_exists=false" >> $GITHUB_OUTPUT
fi
/─[03:06:28] /home/user/visualsign-parser (fix/cla-duplicate-comments=)
\─<")>< PR_NUMBER=162 ./test.sh 
CLA comment already exists, skipping
./test.sh: line 7: $GITHUB_OUTPUT: ambiguous redirect
/─1 [03:06:38] /home/user/visualsign-parser (fix/cla-duplicate-comments=)
\─<")>< PR_NUMBER=168 ./test.sh
No CLA comment found, will post one
./test.sh: line 10: $GITHUB_OUTPUT: ambiguous redirect
/─1 [03:06:53] /home/user/visualsign-parser (fix/cla-duplicate-comments=)
Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

note that the $GITHUB_OUTPUT: ambiguous redirect can be ignored... this shouldn't occur when it runs within the Github Action vs my local machine. its a special variable not defined in my machine but yes defined within Github Actions ( proved by its usage in the previous step in this file )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test on recent changes to use URL as the grep key 🟢

Image

@lukehalasy-anchorage
Copy link
Contributor Author

we can test at least the command within this.

gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions[bot]") | .body' | grep -q "Contributor License Agreement"

the script, ( supposedly), if this is true will skip. we can run this against a PR that has such a CLA comment like #162

see https://github.com/anchorageoss/visualsign-parser/pull/168/changes#r2772045200

@lukehalasy-anchorage lukehalasy-anchorage marked this pull request as ready for review February 6, 2026 03:13
@lukehalasy-anchorage lukehalasy-anchorage changed the title [draft] cla-file-check GitHub action - check before again and again posting about the CLA that needs signing by the contributor. cla-file-check GitHub action - check before again and again posting about the CLA that needs signing by the contributor. Feb 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Check if github-actions bot has already commented about CLA on this PR
COMMENTS=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions") | .body')

if echo "$COMMENTS" | grep -q "Contributor License Agreement"; then
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The grep pattern "Contributor License Agreement" is fragile because it depends on exact matching of this phrase. If the comment text in the "Comment on PR if user is not signed" step (line 65-69) is ever modified to use different wording (e.g., abbreviated as "CLA" or rephrased), this check will fail to detect existing comments and duplicate comments will be posted. Consider using a more stable identifier or searching for a unique marker that's less likely to change, such as the CLA_URL environment variable value.

Suggested change
if echo "$COMMENTS" | grep -q "Contributor License Agreement"; then
if echo "$COMMENTS" | grep -Fq "${{ env.CLA_URL }}"; then

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ya that's a good call.....

@lukehalasy-anchorage lukehalasy-anchorage marked this pull request as draft February 6, 2026 03:20
@lukehalasy-anchorage lukehalasy-anchorage marked this pull request as ready for review February 6, 2026 03:41
lukehalasy-anchorage and others added 4 commits February 6, 2026 13:53
Previously, the CLA workflow would post a comment asking the user to sign
the CLA on every commit pushed to a PR. This created noise and made PR
reviewing harder.

Now the workflow checks if a CLA comment already exists before posting,
ensuring users only get notified once per PR.

Fixes #54

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The github-actions bot's author login is "github-actions", not
"github-actions[bot]". This fixes the duplicate comment issue by
correctly detecting existing CLA comments.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Capture comments in a variable first, then check for CLA text.
This makes the logic clearer and handles the case where no
comments exist without cryptic error handling.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Search for the CLA URL in existing comments rather than the text "Contributor License Agreement" for more robust duplicate detection. The URL is a stable, unique identifier that won't break if comment wording changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

@prasanna-anchorage prasanna-anchorage left a comment

Choose a reason for hiding this comment

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

thanks

@lukehalasy-anchorage lukehalasy-anchorage merged commit 796c70b into main Feb 7, 2026
5 checks passed
@lukehalasy-anchorage lukehalasy-anchorage deleted the fix/cla-duplicate-comments branch February 7, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Don't pester the user to sign CLA multiple times in same PR

3 participants