Fix PR check CI failure on fork PRs (403 when posting comment)#1803
Merged
mre merged 3 commits intoanalysis-tools-dev:masterfrom Apr 11, 2026
Merged
Fix PR check CI failure on fork PRs (403 when posting comment)#1803mre merged 3 commits intoanalysis-tools-dev:masterfrom
mre merged 3 commits intoanalysis-tools-dev:masterfrom
Conversation
Member
|
Thanks, yes, I believe that could work. Code looks fine to me. Merging. Let's see if that makes it work. |
Member
|
One downside is that it's failing the build if we don't touch an tool yaml files. Would you like to send a follow-up PR? 😊 |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
PR Checkworkflow fails with a 403 when run on pull requests from forks:This happens because GitHub Actions intentionally restricts the
GITHUB_TOKENto read-only permissions for fork PRs — even when the workflow declares
pull-requests: write. The check itself runs fine; it only fails when tryingto post the comment.
Fix
This uses the standard split-workflow pattern for fork-safe comment posting:
pr-check.yml— dropspull-requests: write(no longer needed). Whentriggered by a
pull_requestevent, passesCOMMENT_OUTPUT_FILEto thebinary so the rendered comment is written to a file instead of posted via
the API. Saves the file + PR number as a workflow artifact. Still exits
non-zero when criteria are not met, so the check correctly blocks the PR.
pr-comment.yml(new) — triggered byworkflow_runonPR Check completed. Downloads the artifact and posts/updates the comment using thefull
pull-requests: writetoken, whichworkflow_runjobs have even forfork PRs.
ci/pr-check/src/main.rs— honours a newCOMMENT_OUTPUT_FILEenvvar: when set, writes the rendered comment body to that path instead of
posting via the API. Falls back to the existing API-posting path when the
var is absent (preserves the
workflow_dispatchmanual-run behaviourunchanged).
No changes to the YAML schema, contributing criteria, or comment template.