Skip to content

Replace PUBLISH_DOCS_TOKEN with Token Exchange Service token - #342

Merged
Mrtenz merged 4 commits into
mainfrom
use-token-exchange-service-for-publishing-docs
Sep 2, 2026
Merged

Replace PUBLISH_DOCS_TOKEN with Token Exchange Service token#342
Mrtenz merged 4 commits into
mainfrom
use-token-exchange-service-for-publishing-docs

Conversation

@mcmire

@mcmire mcmire commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Currently, to set up docs for a module template–derived repo, you must create a metamaskbot PAT for the repo and set it under PUBLISH_DOCS_TOKEN. However, metamaskbot PATs are deprecated in favor of the Token Exchange Service. This commit updates the docs publishing workflow (and dependent workflows) to make use of the Token Exchange Service.


Note

Medium Risk
Changes how production docs reach GitHub Pages; misconfigured Token Exchange policies could block publishes, though the workflow degrades with a clear warning rather than using a stale PAT.

Overview
Docs publishing no longer uses per-repo PUBLISH_DOCS_TOKEN secrets. The reusable publish-docs workflow obtains a short-lived contents: write token via MetaMask’s get-token action and vars.TOKEN_EXCHANGE_URL, then passes it to peaceiris/actions-gh-pages.

Callers (publish-main-docs, publish-rc-docs, publish-release, and main) drop the PUBLISH_DOCS_TOKEN secret wiring and add id-token: write where they invoke docs publish. Checkout, build, and deploy run only when token exchange succeeds; if it fails (continue-on-error), the job emits a workflow warning about registering a Token Exchange policy instead of failing opaquely.

Reviewed by Cursor Bugbot for commit abf614e. Bugbot is set up for automated code reviews on this repo. Configure here.

Currently, to set up docs for a module template–derived repo, you must
create a `metamaskbot` PAT for the repo and set it under
`PUBLISH_DOCS_TOKEN`. However, `metamaskbot` PATs are deprecated in
favor of the Token Exchange Service. This commit updates docs publishing
workflow (and dependent workflows) to make use of the Token Exchange
Service.
@mcmire
mcmire requested a review from a team as a code owner September 1, 2026 19:52
# This `PUBLISH_DOCS_TOKEN` needs to be manually set per-repository.
# Look in the repository settings under "Environments", and set this token in the `github-pages` environment.
personal_token: ${{ secrets.PUBLISH_DOCS_TOKEN }}
# A policy must be registered for this repo and workflow

@mcmire mcmire Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't added a policy for this repo, so with this change, the docs publishing workflow will no longer work. I'm okay with this considering this repo is just a template, but I can add it if we feel that seeing an X when viewing history for this repo would be confusing. Or maybe we can add a conditional around this workflow so that it doesn't run for template repos?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make it exit with code 0 if it fails to get a token?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the get-token action fails, wouldn't it cause the workflow to fail too?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's why I'm suggesting we add an exit 0 step if the get-token step failed 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry I misread your comment 😅

Yeah, that makes sense. I forgot that sometimes teams don't want to publish docs for their library, and if that's the case they shouldn't be penalized for it.

What do you think about something like this? 63173fb

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Comment thread .github/workflows/publish-docs.yml
@cursor
cursor Bot requested review from Gudahtt and Mrtenz September 1, 2026 19:58

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 63173fb. Configure here.

Comment thread .github/workflows/publish-docs.yml
@Mrtenz
Mrtenz merged commit 4c62af1 into main Sep 2, 2026
29 checks passed
@Mrtenz
Mrtenz deleted the use-token-exchange-service-for-publishing-docs branch September 2, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants