Make the notebook site cross-origin isolated on GitHub Pages (#90) #45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: [master] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Cache emsdk | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/emsdk | |
| key: emsdk-${{ runner.os }}-${{ hashFiles('emsdk_manifest.txt') }} | |
| - name: Install emsdk | |
| run: | | |
| if [ ! -d "$HOME/emsdk" ]; then | |
| git clone https://github.com/emscripten-core/emsdk.git "$HOME/emsdk" | |
| fi | |
| cd "$HOME/emsdk" | |
| ./emsdk install "$(tr -d '[:space:]' < "$GITHUB_WORKSPACE/emsdk_manifest.txt")" | |
| ./emsdk activate "$(tr -d '[:space:]' < "$GITHUB_WORKSPACE/emsdk_manifest.txt")" | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Build lammps.js (the demo links the local package) | |
| run: | | |
| source "$HOME/emsdk/emsdk_env.sh" | |
| export EMSDK_PATH="$HOME/emsdk" | |
| npm ci | |
| npm run build | |
| npm run build:wasm:kokkos | |
| - name: Build demo | |
| run: | | |
| cd examples/pages | |
| npm ci | |
| npm run build | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| # The JupyterLite notebook site ships inside the same Pages artifact, | |
| # at /notebook/. build.sh also copies the built lammps.js dist into | |
| # the site (the notebooks import it from {site}/lammps/client.js). | |
| - name: Build notebook site (JupyterLite) | |
| run: | | |
| python -m pip install -r examples/notebook/requirements.txt | |
| bash examples/notebook/build.sh "$GITHUB_WORKSPACE/examples/pages/dist/notebook" | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: examples/pages/dist | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url || steps.deployment-retry.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| # The Pages backend intermittently returns "Deployment failed, try | |
| # again later" even when the artifact is fine. Tolerate one such | |
| # transient failure and retry rather than failing the whole run. | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| continue-on-error: true | |
| - name: Deploy to GitHub Pages (retry) | |
| id: deployment-retry | |
| if: steps.deployment.outcome == 'failure' | |
| uses: actions/deploy-pages@v4 |