Skip to content

Trigger forward-port on pull_request_target - #5047

Merged
ThaminduDilshan merged 1 commit into
thunder-id:mainfrom
ThaminduDilshan:forwardport-target-main
Aug 18, 2026
Merged

Trigger forward-port on pull_request_target#5047
ThaminduDilshan merged 1 commit into
thunder-id:mainfrom
ThaminduDilshan:forwardport-target-main

Conversation

@ThaminduDilshan

@ThaminduDilshan ThaminduDilshan commented Aug 18, 2026

Copy link
Copy Markdown
Member

Purpose

The forward-port workflow was not triggering for merged PRs on 1.0.x. After switching the trigger to pull_request_target (#5043), merges into 1.0.x (#5040) produced zero runs.

Root cause: pull_request and pull_request_target resolve the workflow file from different refs.

Trigger Workflow file resolved from Secrets for fork PRs
pull_request the PR's base branch (1.0.x) withheld
pull_request_target the repository default branch (main) available

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. The pull_request_target trigger was added only to 1.0.x (#5043), so it was never registered. It must live on main.

Contributor PRs are merged from forks, and pull_request withholds secrets for fork PRs, so secrets.THUNDER_AUTOMATION_BOT resolved to empty and actions/checkout failed with Input required and not supplied: token. pull_request_target runs with secrets and a write-scoped token even for fork PRs.

Approach

Change main's copy of the workflow trigger from pull_request to pull_request_target. The branches: ["1.0.x"] filter still applies to the PR's base ref, so the workflow only fires for merges into 1.0.x, runs in main'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, so pull_request_target is 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_target ignores non-default-branch definitions, so it never triggers and does not conflict with this one.

Related Issues

  • N/A

Related PRs

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
    • Ran Vale and fixed all errors and warnings
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated the automation workflow trigger for closed pull requests on the configured patch branch.

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>
@ThaminduDilshan ThaminduDilshan added the skip-changelog Skip generating changelog for a particular PR label Aug 18, 2026
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f2b182a9-b72c-4dc6-a44e-7a0371cbd5ee

📥 Commits

Reviewing files that changed from the base of the PR and between 394140c and b909386.

📒 Files selected for processing (1)
  • .github/workflows/forward-port-pr.yml

Included review availability: Your plan includes up to 4 reviews per rolling hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The forward-port workflow trigger changes from pull_request to pull_request_target for closed pull requests on the configured patch branch.

Changes

Forward-port workflow

Layer / File(s) Summary
Update workflow trigger
.github/workflows/forward-port-pr.yml
The workflow now uses pull_request_target instead of pull_request.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to b9093

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)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main change: switching the forward-port workflow trigger to pull_request_target.
Description check ✅ Passed The description explains the purpose, root cause, approach, security considerations, related PRs, and checklist status with sufficient detail.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ThaminduDilshan ThaminduDilshan added the trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes label Aug 18, 2026
@ThaminduDilshan ThaminduDilshan changed the title Trigger forward-port on pull_request_target so it runs with secrets Trigger forward-port on pull_request_target Aug 18, 2026
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ThaminduDilshan
ThaminduDilshan added this pull request to the merge queue Aug 18, 2026
Merged via the queue into thunder-id:main with commit 2b05d60 Aug 18, 2026
70 of 71 checks passed
@ThaminduDilshan
ThaminduDilshan deleted the forwardport-target-main branch August 18, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Skip generating changelog for a particular PR trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants