|
| 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 }} |
0 commit comments