-
Notifications
You must be signed in to change notification settings - Fork 645
ci: add issue comment support for status checks #7203
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
Conversation
|
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.
Pull Request Overview
This PR adds support for triggering status check overrides via issue comments, specifically to enable CI bypass for pull requests from forks where the label-based workflow doesn't work due to permission restrictions.
Key Changes:
- Adds
issue_commentevent trigger to the workflow - Implements a new command-based flow using
.skip-integration-checkscomment - Updates permissions to include
issues: writefor comment interactions
| - name: Override status checks for issue comment | ||
| if: ${{ github.event_name == 'issue_comment' && steps.command.outputs.continue == 'true' }} | ||
| run: | |
Copilot
AI
Nov 17, 2025
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.
The issue_comment event from forks is potentially unsafe because the workflow runs in the context of the base repository with elevated permissions (issues: write, pull-requests: write, statuses: write), but can be triggered by external contributors commenting on a PR.
While the github/command action provides some protection by requiring a specific command and permissions check, you should ensure that:
- The action properly validates that the commenter has the required permissions in the repository
- The
permissions: writeparameter correctly restricts to users with write access
Consider adding an explicit permission check or documenting the security model, especially since this is designed to work with PRs from forks where the PR author may not have write access.
| - name: Override status checks for issue comment | |
| if: ${{ github.event_name == 'issue_comment' && steps.command.outputs.continue == 'true' }} | |
| run: | | |
| - name: Check comment author permissions | |
| if: ${{ github.event_name == 'issue_comment' && steps.command.outputs.continue == 'true' }} | |
| id: author-permissions | |
| run: | | |
| AUTHOR="${{ github.event.comment.user.login }}" | |
| PERMISSION=$(gh api "/repos/${{ github.repository }}/collaborators/$AUTHOR/permission" --jq '.permission') | |
| echo "Author permission: $PERMISSION" | |
| if [[ "$PERMISSION" == "admin" || "$PERMISSION" == "write" || "$PERMISSION" == "maintain" ]]; then | |
| echo "has_write_access=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_write_access=false" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GH_TOKEN: ${{ steps.generate_primer_token.outputs.token }} | |
| - name: Override status checks for issue comment | |
| if: ${{ github.event_name == 'issue_comment' && steps.command.outputs.continue == 'true' && steps.author-permissions.outputs.has_write_access == 'true' }} | |
| run: | |
| - name: Override status checks for issue comment | ||
| if: ${{ github.event_name == 'issue_comment' && steps.command.outputs.continue == 'true' }} | ||
| run: | | ||
| SHA=$(gh pr view $NUMBER --json headRefOid --jq '.headRefOid') | ||
| gh api -X POST "/repos/primer/react/statuses/$SHA" \ | ||
| -f state='success' \ | ||
| -f context='github-ui / ci' \ | ||
| -f description='Manual override' \ | ||
| -f target_url="$COMMENT_URL" | ||
| gh api -X POST "/repos/primer/react/statuses/$SHA" \ | ||
| -f state='success' \ | ||
| -f context='github-ui / projects' \ | ||
| -f description='Manual override' \ | ||
| -f target_url="$COMMENT_URL" |
Copilot
AI
Nov 17, 2025
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.
The step "Override status checks for issue comment" lacks error handling when the gh pr view command fails. If NUMBER refers to an issue instead of a pull request (which is possible with the current issue_comment trigger), this command will fail.
Consider adding error handling or verifying the command succeeded before proceeding with the API calls:
run: |
if ! SHA=$(gh pr view $NUMBER --json headRefOid --jq '.headRefOid' 2>/dev/null); then
echo "Failed to get PR information for issue #$NUMBER"
exit 1
fi
# ... rest of the scriptCo-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Unfortunately our labeling workflow won't work if the PR is one from a fork 😞 Trying out one related to issue_comment so that we could have CI pass on PRs from forks.