Merge pull request #23 from ScienceLiveHub/fix/quote-comment-500-stan… #52
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: Build and Deploy Jupyter Book | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| ready: ${{ steps.guard.outputs.ready }} | |
| pages_enabled: ${{ steps.pages_check.outputs.pages_enabled }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| # Single source of truth — see .github/actions/check-ready. | |
| - name: Check repository readiness | |
| id: guard | |
| uses: ./.github/actions/check-ready | |
| - name: Check whether GitHub Pages is enabled | |
| id: pages_check | |
| if: steps.guard.outputs.ready == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if gh api "repos/${{ github.repository }}/pages" >/dev/null 2>&1; then | |
| echo "::notice::GitHub Pages is enabled — Jupyter Book will deploy." | |
| echo "pages_enabled=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "::notice::GitHub Pages is not yet enabled on this repo. Build will run; deploy will be skipped. Enable Pages at https://github.com/${{ github.repository }}/settings/pages (Source: GitHub Actions) to enable deploy on the next push." | |
| echo "pages_enabled=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Set up pixi | |
| if: steps.guard.outputs.ready == 'true' | |
| uses: prefix-dev/setup-pixi@v0.9.6 | |
| with: | |
| pixi-version: v0.68.1 | |
| locked: true | |
| cache: true | |
| environments: docs | |
| - name: Convert .py notebooks to .ipynb | |
| if: steps.guard.outputs.ready == 'true' | |
| run: | | |
| for nb in notebooks/*.py; do | |
| pixi run jupytext --to notebook "$nb" | |
| done | |
| # Glob, not a hard-coded list — new notebooks are picked up automatically. | |
| - name: Execute notebooks | |
| if: steps.guard.outputs.ready == 'true' | |
| run: | | |
| for nb in notebooks/*.ipynb; do | |
| echo "::group::Executing $nb" | |
| pixi run jupyter execute --inplace "$nb" | |
| echo "::endgroup::" | |
| done | |
| - name: Build MyST site | |
| if: steps.guard.outputs.ready == 'true' | |
| env: | |
| # MyST silently ignores `base_url` in myst.yml — only this env var | |
| # works. See docs/cicd-conventions.md. | |
| BASE_URL: /${{ github.event.repository.name }} | |
| run: pixi run -e docs myst build --html | |
| - name: Upload pages artifact | |
| if: steps.guard.outputs.ready == 'true' | |
| uses: actions/upload-pages-artifact@v5 | |
| with: | |
| path: _build/html | |
| deploy: | |
| needs: build | |
| if: needs.build.outputs.ready == 'true' && needs.build.outputs.pages_enabled == 'true' | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |