Trigger forward-port on pull_request_target - #5047
Conversation
The forward-port workflow used pull_request, which resolves its file from the PR base branch and withholds secrets when the PR head is a fork. Merged contributor PRs come from forks, so secrets.THUNDER_AUTOMATION_BOT resolved to empty and actions/checkout failed with "Input required and not supplied: token". pull_request_target resolves the workflow file from the default branch and runs with secrets and a write-scoped token even for fork PRs. It must therefore live on main, not on 1.0.x; the branches filter still restricts it to PRs whose base is 1.0.x. The workflow checks out the trusted target branch and cherry-picks PR commits by SHA (it never executes fork head code), so pull_request_target is safe here. Refs thunder-id#5037, thunder-id#5043 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: ThaminduDilshan <35653110+ThaminduDilshan@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan includes up to 4 reviews per rolling hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe forward-port workflow trigger changes from ChangesForward-port workflow
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This localized workflow change updates when forward-port automation runs; no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Purpose
The forward-port workflow was not triggering for merged PRs on
1.0.x. After switching the trigger topull_request_target(#5043), merges into1.0.x(#5040) produced zero runs.Root cause:
pull_requestandpull_request_targetresolve the workflow file from different refs.pull_request1.0.x)pull_request_targetmain)Per GitHub docs,
pull_request_target"will only trigger a workflow run if the workflow file exists on the default branch" and runs in the default branch context. Thepull_request_targettrigger was added only to1.0.x(#5043), so it was never registered. It must live onmain.Contributor PRs are merged from forks, and
pull_requestwithholds secrets for fork PRs, sosecrets.THUNDER_AUTOMATION_BOTresolved to empty andactions/checkoutfailed withInput required and not supplied: token.pull_request_targetruns with secrets and a write-scoped token even for fork PRs.Approach
Change
main's copy of the workflow trigger frompull_requesttopull_request_target. Thebranches: ["1.0.x"]filter still applies to the PR's base ref, so the workflow only fires for merges into1.0.x, runs inmain's context, and has access to secrets.Security: the job checks out the trusted target branch (
main) and cherry-picks the original PR's commits by SHA. It never checks out or executes fork head code, sopull_request_targetis safe here. The forward-ported changes land in a new PR that goes through normal review and CI.The inert copy left on
1.0.x(from #5037/#5043) is harmless:pull_request_targetignores non-default-branch definitions, so it never triggers and does not conflict with this one.Related Issues
Related PRs
Checklist
breaking changelabel added.Security checks
🤖 Generated with Claude Code
Summary by CodeRabbit