Skip to content

Post CI failure comments on fork PRs via workflow_run#52

Merged
brylie merged 1 commit into
mainfrom
feature/fork-pr-comment-via-workflow-run
Jun 28, 2026
Merged

Post CI failure comments on fork PRs via workflow_run#52
brylie merged 1 commit into
mainfrom
feature/fork-pr-comment-via-workflow-run

Conversation

@brylie

@brylie brylie commented Jun 28, 2026

Copy link
Copy Markdown
Member

Summary

  • Confirmed via PR feat: Add date and time awareness tool (#20) #49 (a fork PR from AlyanPremani05/tapio) that the sticky CI comment never posts for fork-originated PRs: GITHUB_TOKEN is read-only for pull_request runs triggered by forks, the comment POST fails with 403 Resource not accessible by integration, and continue-on-error hides the failure completely.
  • report's "Build PR comment" step now writes the comment body to a pr-comment.json artifact instead of posting it directly, and the job no longer needs/has pull-requests: write.
  • New comment-on-pr.yml workflow triggers on workflow_run once CI completes, downloads that artifact, and posts/updates the sticky comment. workflow_run always executes using this file as committed on main with the base repo's own permissions, regardless of which fork triggered the original run -- nothing from the PR branch executes in this second workflow.
  • The PR number is taken from the artifact (recorded from the original run's trusted context.issue.number), not from workflow_run's own pull_requests field, which GitHub doesn't reliably populate for fork-triggered runs.

Test plan

  • actionlint and prek pass on both workflow files
  • Re-run CI on PR feat: Add date and time awareness tool (#20) #49 (fork PR) and confirm the sticky comment now appears with the failure details and CONTRIBUTING.md links
  • Confirm same-repo PRs still get the comment (and that it still updates in place across reruns rather than duplicating)
  • Confirm a push to main doesn't trigger comment-on-pr.yml into doing anything (no artifact uploaded, no PR event)

The "report" job's PR comment step was failing silently (403 Resource
not accessible by integration) for every fork-originated PR, since
GITHUB_TOKEN is read-only for pull_request runs triggered by forks.
Confirmed against PR #49 (a fork PR): the comment body was built
correctly but the POST itself was rejected, and continue-on-error
hid the failure entirely -- no comment ever appeared.

Split the work in two: "report" now builds the comment body and
uploads it as an artifact instead of posting it directly, dropping
its pull-requests: write permission since it no longer needs it. A
new workflow, comment-on-pr.yml, triggers on workflow_run once CI
completes and posts/updates the comment from there -- workflow_run
always runs with the base repo's own permissions using this file as
committed on the default branch, regardless of which fork triggered
the original run, so it works for both fork and same-repo PRs without
granting fork code any elevated token access.
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@brylie, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 14 minutes and 33 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 43b0a648-5ec4-44d0-b329-178989805bc3

📥 Commits

Reviewing files that changed from the base of the PR and between f0a2ca9 and e1f73fd.

📒 Files selected for processing (2)
  • .github/workflows/ci.yaml
  • .github/workflows/comment-on-pr.yml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fork-pr-comment-via-workflow-run

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brylie brylie merged commit a9b78f0 into main Jun 28, 2026
6 checks passed
@brylie brylie deleted the feature/fork-pr-comment-via-workflow-run branch June 28, 2026 15:18
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant