Skip to content

Commit dc93361

Browse files
ci: Correct permissions for GitHub Pages publishing (#4066)
Add `id-token: write` to CI workflows that try to use token exchange service for publishing to GitHub Pages. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > CI-only permission tightening aligned with existing token-exchange deploy; no application or runtime behavior changes. > > **Overview** > Updates GitHub Actions **permissions** on every job that calls the reusable `publish-github-pages` workflow so publishing can use the MetaMask **token exchange** path instead of relying on `contents: write` on `GITHUB_TOKEN`. > > Each affected job now sets **`contents: read`** and **`id-token: write`** (replacing **`contents: write`**). The same change is applied in the reusable workflow’s `publish-environment` job. Call sites include main-branch doc/schema publishing, release-time docs/schema/test-snaps Pages deploys, and the shared workflow definition. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit cfd4480. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 02eb9e1 commit dc93361

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

.github/workflows/publish-github-pages.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ jobs:
1919
runs-on: ubuntu-latest
2020
environment: github-pages
2121
permissions:
22-
contents: write
22+
contents: read
23+
id-token: write
2324
steps:
2425
- name: Ensure `build_script` is not empty
2526
if: ${{ inputs.destination_dir == '' }}

.github/workflows/publish-main-docs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ jobs:
99
publish-to-gh-pages:
1010
name: Publish docs to `staging` directory of `gh-pages` branch
1111
permissions:
12-
contents: write
12+
contents: read
13+
id-token: write
1314
uses: ./.github/workflows/publish-github-pages.yml
1415
with:
1516
build_script: yarn workspace @metamask/snaps-sdk build:docs
@@ -21,7 +22,8 @@ jobs:
2122
needs:
2223
- publish-to-gh-pages
2324
permissions:
24-
contents: write
25+
contents: read
26+
id-token: write
2527
uses: ./.github/workflows/publish-github-pages.yml
2628
with:
2729
build_script: yarn workspace @metamask/snaps-rpc-methods build:schema

.github/workflows/publish-release.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ jobs:
131131
name: Publish schema to `schema/latest` directory of `gh-pages` branch
132132
needs: publish-release
133133
permissions:
134-
contents: write
134+
contents: read
135+
id-token: write
135136
uses: ./.github/workflows/publish-github-pages.yml
136137
with:
137138
build_script: yarn workspace @metamask/snaps-rpc-methods build:schema
@@ -170,7 +171,8 @@ jobs:
170171
needs: is-sdk-release
171172
if: ${{ needs.is-sdk-release.outputs.IS_SDK_RELEASE == 'true' }}
172173
permissions:
173-
contents: write
174+
contents: read
175+
id-token: write
174176
uses: ./.github/workflows/publish-github-pages.yml
175177
with:
176178
build_script: yarn workspace @metamask/snaps-sdk build:docs
@@ -181,7 +183,8 @@ jobs:
181183
name: Publish docs to `docs/latest` directory of `gh-pages` branch
182184
needs: publish-docs-to-gh-pages
183185
permissions:
184-
contents: write
186+
contents: read
187+
id-token: write
185188
uses: ./.github/workflows/publish-github-pages.yml
186189
with:
187190
build_script: yarn workspace @metamask/snaps-sdk build:docs
@@ -306,7 +309,8 @@ jobs:
306309
needs: is-test-snaps-release
307310
if: ${{ needs.is-test-snaps-release.outputs.IS_TEST_SNAPS_RELEASE == 'true' }}
308311
permissions:
309-
contents: write
312+
contents: read
313+
id-token: write
310314
uses: ./.github/workflows/publish-github-pages.yml
311315
with:
312316
build_script: yarn workspace @metamask/test-snaps build
@@ -320,7 +324,8 @@ jobs:
320324
- publish-test-snaps
321325
if: ${{ needs.is-test-snaps-release.outputs.IS_TEST_SNAPS_RELEASE == 'true' }}
322326
permissions:
323-
contents: write
327+
contents: read
328+
id-token: write
324329
uses: ./.github/workflows/publish-github-pages.yml
325330
with:
326331
build_script: yarn workspace @metamask/test-snaps build

0 commit comments

Comments
 (0)