Commit 667412b
fix(INFRA-3631): add job-level permissions to shadow CI caller (#30252)
## **Description**
This PR finishes **INFRA-3631** Namespace shadow CI work in two parts:
**1. `workflow_call` permission cap (startup fix)**
With `workflow_call`, the caller job’s permissions cap the callee. The
`shadow-ci` caller job in `ci.yml` now declares the permissions
downstream jobs need (`id-token`, `statuses`, `issues`, `pull-requests`,
etc.) so shadow runs do not hit `startup_failure` (see TEC-54198 / prior
validation runs in this thread).
**2. Token Exchange for shadow dispatch (latest)**
The `ci-namespace-shadow.yml` dispatcher no longer uses a dedicated
GitHub App (`create-github-app-token`). It follows the same pattern as
`triage-forwarder.yml`: **OIDC** (`id-token: write`, audience
`api://token-exchange-service`) → **`POST
$TOKEN_EXCHANGE_URL/api/exchange/token`** with `targetRepo` = this repo
and scoped `requested_permissions` (`metadata`/`contents` read,
`actions` write).
- **TES policy** (binds minted tokens to this workflow file via GitHub
OIDC claim **`workflow_ref`**, not `job_workflow_ref`): deploy
**[token-exchange-service#77](consensys-vertical-apps/token-exchange-service#77
before relying on exchange in production.
- **Fork PRs**: the dispatcher job is skipped when
`pull_request.head.repo != github.repository`, so OIDC exchange never
runs for untrusted forks.
- **Duplicate side effects**: `ci.yml` gates status/comment/bundle steps
when `runner_provider=namespace` so shadow runs stay read-mostly at the
GitHub API layer.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes:
[INFRA-3631](https://consensyssoftware.atlassian.net/browse/INFRA-3631)
Related: TEC-54198 (TechOps — `workflow_call` permission inheritance)
Token exchange policy PR:
[consensys-vertical-apps/token-exchange-service#77](consensys-vertical-apps/token-exchange-service#77)
## **Manual testing steps**
```gherkin
Feature: Namespace shadow CI dispatcher
Scenario: Shadow workflow uses token exchange after TES deploy
Given TOKEN_EXCHANGE_URL is set and TES policy from PR #77 is deployed
When a non-fork pull_request triggers ci-namespace-shadow.yml
Then the dispatch job exchanges OIDC for a token and successfully workflow_dispatch'es ci.yml with runner_provider=namespace
Scenario: Fork PR does not call token exchange
Given a pull request from a fork head repository
When ci-namespace-shadow.yml runs
Then the dispatch job is skipped and no exchange request is made
```
## **Screenshots/Recordings**
N/A (CI / GitHub Actions only.)
### **Before**
N/A
### **After**
N/A
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
#### Performance checks (if applicable)
- [ ] I've tested on Android
- [ ] I've tested with a power user scenario
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!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.yml` via `workflow_dispatch` instead 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: write` token) 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.yml` to accept optional `pr_number`/`head_sha` inputs
(used for `run-name` correlation) and to **disable side-effecting
behavior** on `runner_provider=namespace` (e.g., commit status
publishing, bundle-size shipping, PR comments, fixture-validation
reporting) to avoid duplicate statuses/comments and external pushes.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
e65e564. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
[INFRA-3631]:
https://consensyssoftware.atlassian.net/browse/INFRA-3631?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
---------
Co-authored-by: Borislav Grigorov <11405770+bsgrigorov@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 5bfd071 commit 667412b
2 files changed
Lines changed: 178 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
3 | 36 | | |
4 | 37 | | |
5 | 38 | | |
6 | 39 | | |
7 | | - | |
8 | | - | |
9 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
10 | 43 | | |
11 | 44 | | |
12 | 45 | | |
13 | | - | |
| 46 | + | |
14 | 47 | | |
15 | 48 | | |
16 | 49 | | |
17 | 50 | | |
18 | 51 | | |
19 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
20 | 57 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
| |||
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
22 | 33 | | |
23 | 34 | | |
24 | 35 | | |
| |||
29 | 40 | | |
30 | 41 | | |
31 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
32 | 51 | | |
33 | 52 | | |
34 | 53 | | |
| |||
124 | 143 | | |
125 | 144 | | |
126 | 145 | | |
| 146 | + | |
127 | 147 | | |
128 | 148 | | |
129 | 149 | | |
| |||
466 | 486 | | |
467 | 487 | | |
468 | 488 | | |
469 | | - | |
| 489 | + | |
470 | 490 | | |
471 | 491 | | |
472 | 492 | | |
| |||
515 | 535 | | |
516 | 536 | | |
517 | 537 | | |
518 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
519 | 541 | | |
520 | 542 | | |
521 | 543 | | |
| |||
975 | 997 | | |
976 | 998 | | |
977 | 999 | | |
978 | | - | |
| 1000 | + | |
979 | 1001 | | |
980 | 1002 | | |
981 | 1003 | | |
| |||
1115 | 1137 | | |
1116 | 1138 | | |
1117 | 1139 | | |
| 1140 | + | |
1118 | 1141 | | |
1119 | 1142 | | |
1120 | 1143 | | |
| |||
0 commit comments