-
-
Notifications
You must be signed in to change notification settings - Fork 18
Replace PUBLISH_DOCS_TOKEN with Token Exchange Service token #342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,6 @@ on: | |
| destination_dir: | ||
| required: true | ||
| type: string | ||
| secrets: | ||
| PUBLISH_DOCS_TOKEN: | ||
| required: true | ||
|
|
||
| jobs: | ||
| publish-docs-to-gh-pages: | ||
|
|
@@ -17,22 +14,38 @@ jobs: | |
| environment: github-pages | ||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
| steps: | ||
| - name: Ensure `destination_dir` is not empty | ||
| if: ${{ inputs.destination_dir == '' }} | ||
| run: exit 1 | ||
| - name: Get access token | ||
| id: get-token | ||
| uses: MetaMask/github-tools/.github/actions/get-token@v1 | ||
| with: | ||
| token-exchange-url: ${{ vars.TOKEN_EXCHANGE_URL }} | ||
| permissions: | | ||
| contents: write | ||
| continue-on-error: true | ||
| - name: Checkout and setup environment | ||
| if: ${{ steps.get-token.outcome == 'success' }} | ||
| uses: MetaMask/action-checkout-and-setup@v3 | ||
| with: | ||
| is-high-risk-environment: true | ||
| persist-credentials: false | ||
| - name: Run build script | ||
| if: ${{ steps.get-token.outcome == 'success' }} | ||
| run: yarn build:docs | ||
| - name: Deploy to `${{ inputs.destination_dir }}` directory of `gh-pages` branch | ||
| if: ${{ steps.get-token.outcome == 'success' }} | ||
| uses: peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935 | ||
| with: | ||
| # 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 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 😅
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good! |
||
| # within the Token Exchange Service. | ||
| personal_token: ${{ steps.get-token.outputs.token }} | ||
| publish_dir: ./docs | ||
| destination_dir: ${{ inputs.destination_dir }} | ||
| - name: Show warning if the get-token step failed | ||
| if: ${{ steps.get-token.outcome == 'failure' }} | ||
| run: | | ||
| echo "::warning::The docs publishing workflow failed because the required token could not be obtained. If you want to publish docs for this repo, you'll need to add a policy to the Token Exchange Service." | ||
|
cursor[bot] marked this conversation as resolved.
|
||
Uh oh!
There was an error while loading. Please reload this page.