fix(ci): fix rerun workflows for fork PRs#13512
Conversation
|
|
Codeowners approval required for this PR:
Show detailed file reviewers |
|
Let me now look closely at the security aspects. The
However, the Let me also check one more thing — the Let me also think about a race condition: if both the codeowners and remote-tests trigger workflows use the artifact name One thing I want to verify — the Now let me look at one potential issue more carefully. In I've thoroughly reviewed the code and I don't see any actionable bugs, security issues, or backward compatibility problems. The approach is well-documented, the permissions are correctly scoped, and edge cases are handled. LGTM |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
For fork PRs, pull_request_review and pull_request events give a read-only GITHUB_TOKEN with no access to secrets. This means the rerun-codeowners and rerun-remote-tests workflows cannot call the Actions API to re-run jobs/workflows. Fix this by splitting each workflow into a trigger + privileged pair: - The trigger workflow fires on the original event, saves PR context (head SHA, targets) as an artifact, and exits. - The privileged workflow fires on workflow_run when the trigger completes. workflow_run always runs from the default branch with full permissions, so it can perform the re-run even for fork PRs. The two privileged workflows use different lookup strategies because of a GitHub API asymmetry: - Codeowners uses check-name lookup: pull_request_target runs are indexed by the base branch SHA, but check runs are on the PR head commit. - Remote tests uses workflow-file lookup: pull_request runs are indexed by the PR head SHA, and E2E job names are matrix-expanded so check-name lookup would be fragile. Also renames rerun_codeowners.yml to rerun-codeowners.yml for consistency with the rest of the workflow files.
Update stale references to the old rerun_codeowners.yml filename and document the new two-workflow design (trigger + privileged) in both CODEOWNERS.md and .github/workflows/README.md. Also adds documentation for the run-c3-frameworks-tests label support.
- rerun-remote-tests.yml: switch from two-workflow artifact pattern to single pull_request_target workflow (simpler, same security) - rerun-codeowners.yml: remove artifact upload/download; privileged workflow now reads head SHA from github.event.workflow_run.head_sha (GitHub-provided metadata, not controllable by fork code) - Delete rerun-remote-tests-privileged.yml (no longer needed)
a25f8b3 to
d4656a6
Compare
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
Fixes the rerun-codeowners workflow failing on fork PRs (e.g. https://github.com/cloudflare/workers-sdk/actions/runs/24451203502/job/71440264028?pr=12456).
For fork PRs,
pull_request_reviewandpull_requestevents give a read-onlyGITHUB_TOKENwith no access to secrets, so the rerun workflows cannot call the Actions API to re-run jobs/workflows.This PR fixes the issue by splitting each rerun workflow into a trigger + privileged pair using the
workflow_runpattern:pull_request_revieworpull_requestlabeled/unlabeled), saves PR context (head SHA, workflow targets) as an artifact, and exits. No privileged API calls.workflow_runwhen the trigger completes.workflow_runalways runs from the default branch with full permissions, so it can perform the re-run even for fork PRs.The two privileged workflows use different lookup strategies because of a GitHub API asymmetry:
rerun-codeowners-privileged.ymlcodeowners.ymlusespull_request_target— its runs are indexed by the base branch SHA, not the PR head. But check runs ARE on the PR head commit, so we find by check name.rerun-remote-tests-privileged.ymlpull_request— their runs are indexed by the PR head SHA. Also, E2E job names are matrix-expanded (e.g. "Wrangler E2E (Linux, shard 1/4)") making check-name lookup fragile.Also renames
rerun_codeowners.yml→rerun-codeowners.ymlfor consistency with the rest of the workflow files.Tests
Public documentation