Skip Claude review for fork PRs#14
Conversation
Fork PRs run with a read-only GITHUB_TOKEN and no access to secrets, so the claude-code-action can't mint an OIDC token or authenticate, and the job fails. Gate the review job on the PR head being in the same repository so fork PRs are skipped cleanly instead of failing.
|
Claude finished @jonathangreen's task in 1m 13s —— View job Code Review
SummaryThe change is correct, minimal, and well-reasoned. The added guard |
Description
Add a same-repository guard to the
reviewjob'sifcondition in the reusable Claude PR review workflow so it only runs for PRs whose head branch lives in the base repository. Fork PRs are now skipped instead of failing.Motivation and Context
For the
pull_requestevent, GitHub runs fork-originated PRs with a read-onlyGITHUB_TOKENand withholds secrets, as a security measure against untrusted code. Under those restrictions theclaude-code-actioncannot mint an OIDC token (the job'sid-token: writeis capped to read for forks) and has noCLAUDE_CODE_OAUTH_TOKEN, so the review job fails withCould not fetch an OIDC token.Example failure on a fork PR: https://github.com/ThePalaceProject/circulation/actions/runs/27349076847/job/80808321565
Rather than have every consumer of this reusable workflow see a failing required-looking check on fork PRs, skip the job cleanly for forks. Same-repo branch PRs are unaffected. Fork support can be added later via a different trigger (e.g.
pull_request_targetor a label gate), which carries its own security tradeoffs.How Has This Been Tested?
Not yet run in CI. The
ifexpression uses standard GitHub Actions context fields (github.event.pull_request.head.repo.full_namevsgithub.repository); a fork PR evaluates the condition to false (job skipped) and a same-repo PR evaluates to true (job runs), preserving the existing dependabot exclusion.Checklist