fix(INFRA-3631): add job-level permissions to shadow CI caller#30252
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
256f96e to
e9a5e8b
Compare
Add job-level permissions to the shadow-ci caller job. With workflow_call the caller's permissions cap the callee — ci.yml jobs declare statuses/issues/pull-requests write, so the caller must grant at least the same or the workflow fails at startup. Write permissions are required for the workflow to start but the shadow should not post duplicate statuses or PR comments. A follow-up will gate those write steps in ci.yml to skip when running under the shadow workflow.
e9a5e8b to
33bcfc1
Compare
Gate the 4 write steps in ci.yml to skip when runner_provider is namespace. This prevents the shadow CI workflow from posting duplicate commit statuses and PR comments while keeping the jobs running for their outputs (fingerprint, E2E selection, fixture validation). - post-build-source-hash: skip status post, keep fingerprint output - js-bundle-size-check: skip commit status post on main - smart-e2e-selection: set post-comment to false - report-fixture-validation: skip PR comment post
Replace workflow_call with gh workflow run so shadow jobs stay out of PR checks (ALLGREEN). Add optional pr_number/head_sha inputs and run-name for correlation. Skip ship-js-bundle-size-check on Namespace shadow to avoid duplicate pushes to mobile_bundlesize_stats. Secrets: wire ACTIONS_WRITE_TOKEN for dispatch; intended token is a fine-grained PAT on this repo with Actions: Read and write (plus Metadata: Read). Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c9f88bf. Configure here.
Replace ACTIONS_WRITE_TOKEN with actions/create-github-app-token and document repo variable/secret names plus required installation permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
Replace GitHub App token with TOKEN_EXCHANGE_URL exchange aligned to TES policy. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Namespace “shadow CI” integration so it can trigger the main ci.yml pipeline without blocking PR checks, and adds correlation inputs/guards to prevent shadow runs from producing duplicate side effects (commit statuses, PR comments, external repo writes).
Changes:
- Adds
run-namepluspr_number/head_shainputs toci.ymlfor better identification/correlation of shadow-dispatched runs. - Gates several side-effecting steps/jobs in
ci.ymlto skip whenrunner_provider == 'namespace'. - Reworks
ci-namespace-shadow.ymlfrom aworkflow_call-based caller to a “fire-and-forget” dispatcher that uses OIDC token exchange +gh workflow runto startci.yml.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| .github/workflows/ci.yml | Adds shadow correlation inputs/run-name and skips side-effecting steps on Namespace runs. |
| .github/workflows/ci-namespace-shadow.yml | Replaces workflow_call with an OIDC-authenticated dispatcher that triggers ci.yml via workflow_dispatch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| name: ci | ||
|
|
||
| run-name: >- | ||
| ${{ inputs.pr_number && format('ci [shadow PR #{0} @ {1}]', inputs.pr_number, inputs.head_sha) || '' }} |
| retry_wait_seconds: 30 | ||
| command: yarn install --immutable | ||
| - name: Post build-source-hash commit status | ||
| if: ${{ inputs.runner_provider != 'namespace' }} |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Neither file touches:
The changes are purely about CI runner orchestration and preventing duplicate side effects in shadow runs. No E2E tests need to run to validate these changes, and no performance tests are warranted. Performance Test Selection: |
|




Description
This PR finishes INFRA-3631 Namespace shadow CI work in two parts:
1.
workflow_callpermission cap (startup fix)With
workflow_call, the caller job’s permissions cap the callee. Theshadow-cicaller job inci.ymlnow declares the permissions downstream jobs need (id-token,statuses,issues,pull-requests, etc.) so shadow runs do not hitstartup_failure(see TEC-54198 / prior validation runs in this thread).2. Token Exchange for shadow dispatch (latest)
The
ci-namespace-shadow.ymldispatcher no longer uses a dedicated GitHub App (create-github-app-token). It follows the same pattern astriage-forwarder.yml: OIDC (id-token: write, audienceapi://token-exchange-service) →POST $TOKEN_EXCHANGE_URL/api/exchange/tokenwithtargetRepo= this repo and scopedrequested_permissions(metadata/contentsread,actionswrite).workflow_ref, notjob_workflow_ref): deploy token-exchange-service#77 before relying on exchange in production.pull_request.head.repo != github.repository, so OIDC exchange never runs for untrusted forks.ci.ymlgates status/comment/bundle steps whenrunner_provider=namespaceso shadow runs stay read-mostly at the GitHub API layer.Changelog
CHANGELOG entry: null
Related issues
Fixes: INFRA-3631
Related: TEC-54198 (TechOps —
workflow_callpermission inheritance)Token exchange policy PR: consensys-vertical-apps/token-exchange-service#77
Manual testing steps
Screenshots/Recordings
N/A (CI / GitHub Actions only.)
Before
N/A
After
N/A
Pre-merge author checklist
Performance checks (if applicable)
Pre-merge reviewer checklist
Note
Medium Risk
Changes GitHub Actions authentication and dispatch flow for shadow CI and conditions out status/comment/publishing steps when running on
namespace, which could affect CI observability or external integrations if misconfigured.Overview
Reworks the Namespace shadow CI workflow to be fire-and-forget by dispatching
ci.ymlviaworkflow_dispatchinstead of calling it directly, so shadow flakes don’t appear as PR checks or block the merge queue.Adds OIDC-based Token Exchange Service authentication (scoped
actions: writetoken) for the dispatcher, skips the dispatcher entirely for fork PRs, and posts a step summary linking the originating PR to the dispatched run.Updates
ci.ymlto accept optionalpr_number/head_shainputs (used forrun-namecorrelation) and to disable side-effecting behavior onrunner_provider=namespace(e.g., commit status publishing, bundle-size shipping, PR comments, fixture-validation reporting) to avoid duplicate statuses/comments and external pushes.Reviewed by Cursor Bugbot for commit e65e564. Bugbot is set up for automated code reviews on this repo. Configure here.