fix(release): pin checkout ref to base repo to avoid v7 fork-PR refusal#168
Merged
Conversation
actions/checkout v7.0.0 refuses to check out fork PR code under pull_request_target. The create_release and release_goreleaser jobs left ref unset, so checkout defaulted to refs/pull/N/merge and failed for any fork-originated PR. Pin both to base-repo refs so the guard is satisfied without opting into allow-unsafe-pr-checkout. ## What/Why Fork-originated PRs could not trigger a release because checkout v7 blocks fork PR refs under pull_request_target; pinning to base-repo refs restores releases while keeping the pwn-request protection intact. ## Proof it works actionlint and pre-commit pass on the workflow. Verified the guard logic in actions/checkout unsafe-pr-checkout-helper.ts: it throws only when the resolved ref matches refs/pull/N/head|merge, which a base branch name or release tag does not. ## Risk + AI role Low. CI-only change to a release workflow. Edits drafted with Claude Opus 4.8, reviewed by a human before commit. ## Review focus The fallback expression on create_release (base.ref for PR events, github.ref for workflow_dispatch) and whether release_goreleaser should build from the tag rather than the merged base branch. Signed-off-by: jmeridth <jmeridth@gmail.com>
1 task
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the reusable release workflow’s actions/checkout steps to explicitly set ref, avoiding actions/checkout v7’s refusal to check out refs/pull/* under pull_request_target runs (notably for fork-originated PRs).
Changes:
- Pin
create_releasecheckout to a base-repo ref instead of the implicitrefs/pull/N/mergedefault. - Pin
release_goreleasercheckout to the newly created release tag (needs.create_release.outputs.full-tag) for consistency with the image release job.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/release.yaml | Sets explicit checkout ref values in release jobs to avoid checkout v7 fork-PR refusal under pull_request_target. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Low
The create_release checkout pins to the base branch tip, not the PR merge commit. Reword the comment to say so and to note that merge_commit_sha is guard-blocked, addressing review feedback on PR #168. Signed-off-by: jmeridth <jmeridth@gmail.com>
zkoppert
approved these changes
Jul 8, 2026
zkoppert
left a comment
Contributor
There was a problem hiding this comment.
👍🏻
- create_release ref: base.ref || github.ref : for a merged fork PR, base.ref is "main" (a bare branch name), so checkout leaves input.commit undefined and input.ref="main" matches none of the three guard conditions. Guard passes, checks out the merged base branch.
- release_goreleaser ref: full-tag : a tag name (non-SHA) leaves input.commit undefined, so the guard passes. The tag is guaranteed present: the job needs: create_release and gates on full-tag != '' , and the tag is pushed in create_release (lines 170-175). This also aligns it with the existing release_image job.
- workflow_dispatch fallback github.ref: the guard early-returns for non-pull_request_target / workflow_run events, so it is fine.
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.
Proposed Changes
actions/checkoutv7.0.0 refuses to check out fork PR code underpull_request_target(the "pwn request" guard added in actions/checkout#2454). Thecreate_releaseandrelease_goreleaserjobs leaverefunset, so underpull_request_targetcheckout defaults torefs/pull/N/merge. For any fork-originated PR this now fails with "Refusing to check out fork pull request code from a 'pull_request_target' workflow," which blocks the release entirely.This pins both checkouts to base-repo refs so the guard is satisfied without opting into
allow-unsafe-pr-checkout(that flag would suppress the guard while still pulling untrusted fork code, re-introducing the pwn-request exposure):create_release:ref: ${{ github.event.pull_request.base.ref || github.ref }}. Checks out the base branch tip for PR-triggered runs, with a fallback forworkflow_dispatch. This tags the base branch tip at release time rather than a specific PR merge commit. The exact-merge refs (merge_commit_sha,head.sha,refs/pull/N/merge) are all in the checkout v7 guard's blocklist, so the base branch is the guard-safe choice, and tagging the accumulated base tip is appropriate for a release-drafter release.release_goreleaser:ref: ${{ needs.create_release.outputs.full-tag }}. Builds from the release tag, matching the existingrelease_imagejob.release_imagealready pinsrefto the tag, so it needs no change.Verification
Per
unsafe-pr-checkout-helper.ts, the refusal fires only when the resolved ref matchesrefs/pull/N/head|mergeor resolves to a PR head/merge SHA; a base branch name or a release tag matches none of these, so the guard passes.actionlintand the repo'spre-commithooks pass on the workflow.Readiness Checklist
Author/Contributor