@@ -19,18 +19,25 @@ name: CI (Namespace shadow)
1919# tab at a glance.
2020# - The dispatcher job posts a GitHub Actions step summary linking the PR
2121# to the dispatched shadow run URL, reachable from the PR Checks tab.
22+ #
23+ # Authentication (GitHub App, not a PAT):
24+ # - Repo variable: SHADOW_CI_DISPATCH_GITHUB_APP_CLIENT_ID (App "Client ID")
25+ # - Repo secret: SHADOW_CI_DISPATCH_GITHUB_APP_PRIVATE_KEY (PEM private key)
26+ # - App must be installed on MetaMask/metamask-mobile with at least:
27+ # Metadata: Read, Contents: Read, Actions: Read and write (installation
28+ # permissions must cover the token's permission-* inputs below).
2229
2330on :
2431 pull_request :
2532 types : [opened, synchronize, reopened, ready_for_review]
2633 paths-ignore :
27- - ' docs/**'
28- - ' **/*.md'
29- - ' .github/CODEOWNERS'
34+ - " docs/**"
35+ - " **/*.md"
36+ - " .github/CODEOWNERS"
3037 push :
3138 branches : [main]
3239 schedule :
33- - cron : ' 0 * * * *'
40+ - cron : " 0 * * * *"
3441 workflow_dispatch :
3542
3643concurrency :
@@ -42,16 +49,26 @@ permissions:
4249
4350jobs :
4451 dispatch-shadow :
45- name : ' [shadow] Dispatch'
52+ name : " [shadow] Dispatch"
4653 runs-on : ubuntu-latest
47- # Skip dispatch for fork PRs: ACTIONS_WRITE_TOKEN is not exposed to forks ,
54+ # Skip dispatch for fork PRs: App credentials are not exposed to fork workflows ,
4855 # and we don't want untrusted PRs consuming Namespace capacity.
4956 if : ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
5057 steps :
58+ - name : Mint GitHub App installation token
59+ id : shadow-dispatch-token
60+ uses : actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3
61+ with :
62+ client-id : ${{ vars.SHADOW_CI_DISPATCH_GITHUB_APP_CLIENT_ID }}
63+ private-key : ${{ secrets.SHADOW_CI_DISPATCH_GITHUB_APP_PRIVATE_KEY }}
64+ permission-metadata : read
65+ permission-contents : read
66+ permission-actions : write
67+
5168 - name : Dispatch ci.yml on Namespace
5269 id : dispatch
5370 env :
54- GH_TOKEN : ${{ secrets.ACTIONS_WRITE_TOKEN }}
71+ GH_TOKEN : ${{ steps.shadow-dispatch-token.outputs.token }}
5572 REPO : ${{ github.repository }}
5673 REF : ${{ github.head_ref || github.ref_name }}
5774 PR_NUMBER : ${{ github.event.pull_request.number || '' }}
0 commit comments