Skip to content

Commit 77a527d

Browse files
Stop checking out the fork PR head in claude-code-review.yml (#53)
actions/checkout refuses to check out a fork PR's head under pull_request_target by default (a hard-coded safety refusal added in a patch-level actions/checkout@v4 release), so review never actually ran against a genuine fork-originated PR — only against same-repo/upstream-branch PRs, which don't hit this check. The fix is not to opt back in via allow-unsafe-pr-checkout: true: claude-code-action already fetches and reads the PR's real content itself, internally, via the base repo's own refs/pull/<n>/head, so there's no reason for this job to put the fork's files in the workspace at all. The checkout step now fetches the base ref only, matching claude-code-action's own documented recommended pattern. Note: pull_request_target always runs the workflow file from the base branch, so this PR's own claude-review check will still run the OLD broken workflow and fail the same way — that's expected, not a sign the fix doesn't work. Verification happens on a subsequent PR, after this merges to master.
1 parent f578dc0 commit 77a527d

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

.github/workflows/claude-code-review.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ name: Claude Code Review
1515
# head lives in this repo or an external fork (an arbitrary external fork
1616
# still can't trigger this secret-bearing job unless it's actually
1717
# jnasbyupgrade's own fork). The workflow file always comes from the base
18-
# branch (master), so a PR cannot modify the reviewer that runs on it. We
19-
# check out the PR head only for read context (persist-credentials: false)
20-
# and never build or execute PR code.
18+
# branch (master), so a PR cannot modify the reviewer that runs on it. The
19+
# checkout step below fetches the BASE ref only, never the PR head -
20+
# claude-code-action fetches and reads the PR's actual content itself,
21+
# internally, via the base repo's own refs/pull/<n>/head (see its
22+
# docs/security.md). Checking out the PR head directly here would put
23+
# untrusted fork content in the workspace for no reason, and actions/checkout
24+
# refuses to do so anyway under pull_request_target without an explicit
25+
# (and here unnecessary) allow-unsafe-pr-checkout: true opt-in.
2126
on:
2227
pull_request_target:
2328
types: [opened, synchronize, reopened, ready_for_review]
@@ -81,14 +86,13 @@ jobs:
8186
echo "decision=$decision" >> "$GITHUB_OUTPUT"
8287
echo "gate decision: $decision"
8388
84-
- name: Check out PR head (read-only context)
89+
- name: Check out base ref
8590
if: steps.gate.outputs.decision == 'run'
8691
# Intentionally tracks the major-version tag (not a pinned SHA) so
87-
# upstream fixes are picked up automatically.
92+
# upstream fixes are picked up automatically. No repository:/ref:
93+
# override - see the SECURITY comment at the top of this file for why.
8894
uses: actions/checkout@v4
8995
with:
90-
repository: ${{ github.event.pull_request.head.repo.full_name }}
91-
ref: ${{ github.event.pull_request.head.sha }}
9296
fetch-depth: 1
9397
persist-credentials: false
9498

0 commit comments

Comments
 (0)