Skip to content

Commit f0db2d5

Browse files
authored
build: ensure browser playground is deployed to gh pages on new releases (#131)
1 parent 1112ea6 commit f0db2d5

2 files changed

Lines changed: 91 additions & 1 deletion

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Deploy Browser Playground to GitHub Pages
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
destination_dir:
7+
required: true
8+
type: string
9+
secrets:
10+
PUBLISH_DOCS_TOKEN:
11+
required: true
12+
workflow_dispatch:
13+
inputs:
14+
destination_dir:
15+
description: 'Destination directory on GitHub Pages (e.g., "latest", "1.0.2", "browser-playground")'
16+
required: true
17+
type: string
18+
19+
jobs:
20+
deploy-browser-playground-to-gh-pages:
21+
name: Deploy Browser Playground to GitHub Pages
22+
runs-on: ubuntu-latest
23+
environment: github-pages
24+
permissions:
25+
contents: write
26+
27+
steps:
28+
- name: Ensure `destination_dir` is not empty
29+
if: ${{ inputs.destination_dir == '' }}
30+
run: exit 1
31+
32+
- uses: actions/checkout@v4
33+
34+
- name: Install Corepack via Node
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version-file: '.nvmrc'
38+
39+
- name: Install Yarn
40+
run: corepack enable
41+
42+
- name: Restore Yarn cache
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version-file: '.nvmrc'
46+
cache: 'yarn'
47+
48+
- name: Install dependencies via Yarn
49+
run: yarn --immutable
50+
51+
- name: Build workspace dependencies
52+
run: |
53+
# Build all packages (workspace dependencies) in topological order
54+
# This ensures @metamask/connect and other dependencies are built first
55+
yarn workspaces foreach --all --topological-dev --verbose --no-private run build
56+
57+
- name: Build browser playground
58+
working-directory: playground/browser-playground
59+
run: yarn build
60+
61+
- name: Deploy to `${{ inputs.destination_dir }}` directory of `gh-pages` branch
62+
uses: peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935
63+
with:
64+
# This `PUBLISH_DOCS_TOKEN` needs to be manually set per-repository.
65+
# Look in the repository settings under "Environments", and set this token in the `github-pages` environment.
66+
personal_token: ${{ secrets.PUBLISH_DOCS_TOKEN }}
67+
publish_dir: ./playground/browser-playground/build
68+
destination_dir: ${{ inputs.destination_dir }}

.github/workflows/publish-release.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,33 @@ jobs:
110110

111111
publish-wagmi-to-latest-gh-pages:
112112
name: Publish Wagmi Integration to `latest` directory of `gh-pages` branch
113-
needs: publish-npm
113+
needs: publish-wagmi-to-gh-pages
114114
permissions:
115115
contents: write
116116
uses: ./.github/workflows/deploy-wagmi-to-gh-pages.yml
117117
with:
118118
destination_dir: latest
119119
secrets:
120120
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}
121+
122+
publish-browser-playground-to-gh-pages:
123+
name: Publish Browser Playground to `${{ needs.get-release-version.outputs.RELEASE_VERSION }}` directory of `gh-pages` branch
124+
needs: get-release-version
125+
permissions:
126+
contents: write
127+
uses: ./.github/workflows/deploy-browser-playground-to-gh-pages.yml
128+
with:
129+
destination_dir: ${{ needs.get-release-version.outputs.RELEASE_VERSION }}
130+
secrets:
131+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}
132+
133+
publish-browser-playground-to-latest-gh-pages:
134+
name: Publish Browser Playground to `latest` directory of `gh-pages` branch
135+
needs: publish-browser-playground-to-gh-pages
136+
permissions:
137+
contents: write
138+
uses: ./.github/workflows/deploy-browser-playground-to-gh-pages.yml
139+
with:
140+
destination_dir: latest
141+
secrets:
142+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}

0 commit comments

Comments
 (0)