Use pull_request_target for e2e tests to support fork PRs#796
Open
kelos-bot[bot] wants to merge 1 commit intomainfrom
Open
Use pull_request_target for e2e tests to support fork PRs#796kelos-bot[bot] wants to merge 1 commit intomainfrom
kelos-bot[bot] wants to merge 1 commit intomainfrom
Conversation
GitHub Actions does not expose repository secrets to pull_request events from forks. Switch the e2e job to trigger on pull_request_target instead, which runs in the base repository context and has access to secrets. The existing ok-to-test label gate ensures maintainer review before secrets are exposed. Non-e2e jobs continue to use pull_request to avoid double runs. The checkout step now explicitly uses the PR head SHA to test the correct code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
2 issues found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/workflows/ci.yaml">
<violation number="1" location=".github/workflows/ci.yaml:9">
P1: Adding `pull_request_target` without separating concurrency groups can cause `pull_request` and `pull_request_target` runs to cancel each other, potentially skipping required CI jobs.</violation>
<violation number="2" location=".github/workflows/ci.yaml:11">
P0: `pull_request_target` on `synchronize` allows newly pushed fork commits to run e2e with secrets as long as a prior `ok-to-test` label remains. Require fresh maintainer re-approval per commit (for example, trigger only on `labeled`).</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| types: [opened, synchronize, reopened, labeled] | ||
| pull_request_target: | ||
| branches: [main] | ||
| types: [opened, synchronize, reopened, labeled] |
There was a problem hiding this comment.
P0: pull_request_target on synchronize allows newly pushed fork commits to run e2e with secrets as long as a prior ok-to-test label remains. Require fresh maintainer re-approval per commit (for example, trigger only on labeled).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/ci.yaml, line 11:
<comment>`pull_request_target` on `synchronize` allows newly pushed fork commits to run e2e with secrets as long as a prior `ok-to-test` label remains. Require fresh maintainer re-approval per commit (for example, trigger only on `labeled`).</comment>
<file context>
@@ -6,6 +6,9 @@ on:
types: [opened, synchronize, reopened, labeled]
+ pull_request_target:
+ branches: [main]
+ types: [opened, synchronize, reopened, labeled]
merge_group:
workflow_dispatch:
</file context>
Suggested change
| types: [opened, synchronize, reopened, labeled] | |
| types: [labeled] |
| pull_request: | ||
| branches: [main] | ||
| types: [opened, synchronize, reopened, labeled] | ||
| pull_request_target: |
There was a problem hiding this comment.
P1: Adding pull_request_target without separating concurrency groups can cause pull_request and pull_request_target runs to cancel each other, potentially skipping required CI jobs.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/ci.yaml, line 9:
<comment>Adding `pull_request_target` without separating concurrency groups can cause `pull_request` and `pull_request_target` runs to cancel each other, potentially skipping required CI jobs.</comment>
<file context>
@@ -6,6 +6,9 @@ on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, labeled]
+ pull_request_target:
+ branches: [main]
+ types: [opened, synchronize, reopened, labeled]
</file context>
This was referenced Mar 26, 2026
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.
/kind bug
What type of PR is this?
Bug fix — e2e tests cannot access secrets for PRs from forked repositories.
What this PR does / why we need it:
GitHub Actions does not expose repository secrets to
pull_requestevents from forks. This PR switches the e2e test job to usepull_request_targetinstead, which runs in the base repository's context and has access to secrets.Changes:
pull_request_targettrigger to the CI workflowpull_request_targetevents to avoid double runspull_request_target(withok-to-testlabel gate) instead ofpull_requestgithub.event.pull_request.head.shato test the PR's actual codeThe existing
ok-to-testlabel gate ensures a maintainer has reviewed the code before secrets are exposed to fork PRs.Which issue(s) this PR is related to:
Fixes #793
Special notes for your reviewer:
The
pull_request_targetevent runs the workflow definition from the base branch (main), not the PR branch. This is the standard secure pattern for running CI with secrets on fork PRs — the workflow itself is trusted (from main), and theok-to-testlabel ensures maintainer approval before secrets are used.Does this PR introduce a user-facing change?
Summary by cubic
Enable e2e tests on forked PRs by switching to
pull_request_target, gated by theok-to-testlabel, so secrets are available safely. Fixes #793.pull_request_targettrigger; e2e runs only when PR hasok-to-test.pull_request_targetand avoid duplicate runs.${{ github.event.pull_request.head.sha || github.sha }}to test the PR’s code.Written for commit daa21c4. Summary will update on new commits.