Add an AI review workflow for pull requests opened from forks - #407
Merged
Conversation
ai-review.yml's own header explains why it does not run on fork PRs: GitHub withholds secrets from pull_request events triggered by forks, and switching to pull_request_target to work around that would run with our secrets against a branch the contributor controls. This adds that coverage back using pull_request_target the way that stays safe: the job never checks out the fork's head (no ref: override, so it resolves to the trusted base branch), the contributor's diff and PR metadata are fetched as plain text through the API and read only by the model, and the only side effect is a rendered PR comment. Findings are fenced as untrusted data with the same defence ai-review.yml already uses for scanner output. Two cost controls, since pull_request_target itself runs with no approval click the way ci.yml's plain pull_request trigger does: external_review.py caps the diff and the reply per call, and the workflow counts its own runs in the trailing 24 hours and skips the paid call past a fixed ceiling. Neither substitutes for a hard spend limit on the API key itself, set before the secret is added. Dormant with no ANTHROPIC_API_KEY secret present, same as ai-review.yml.
… runner test_static_checks_match_ci.py caught this: the new ci.yml step had no entry in tools/static-checks/run.py's CHECKS, so the local runner would report success without having run it.
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.
Summary
`ai-review.yml` deliberately does not run on fork PRs (its own header explains why: GitHub withholds secrets from `pull_request` events on forks, and `pull_request_target` would run with our secrets against a branch the contributor controls). This adds that coverage back the way that stays safe.
How it avoids what ai-review.yml's warning is about
Cost controls
`pull_request_target` itself runs with no approval click, unlike `ci.yml`'s plain `pull_request` trigger. Two things bound spend:
Neither substitutes for a hard spend limit set on the API key or workspace in the Anthropic Console before the secret is added - that's the real backstop.
Status
Dormant: no `ANTHROPIC_API_KEY` secret exists in this repository yet, same as `ai-review.yml`. Every step is skipped and the job succeeds at no cost until one is added.
Verification