diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 3b8dbd9..4768664 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,17 +3,30 @@ name: Deploy Docs on: push: branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +concurrency: + group: "pages-${{ github.ref }}" + cancel-in-progress: true jobs: - docs: + build: runs-on: ubuntu-latest # Forks carry no release tags, so setuptools_scm cannot resolve a version - # here — and a fork has no business publishing to its own gh-pages. + # here. PR builds still run (for debugging) but only against this repo. if: github.repository == 'ARM-DOE/Adapt' - permissions: - contents: write steps: + - name: Check runner Node.js version + run: node --version + # Diagnostic only — confirms which patched Node 20.x binary + # (e.g. relevant to CVE fixes in 22.23.4 / 24.22.1 / 26.12.1 lines) + # is bundled in the current runner image. GitHub-authored actions + # below run on this same runtime; it cannot be pinned from here. - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -22,7 +35,7 @@ jobs: - name: Set up Python uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 with: - python-version: "3.13.17" + python-version: "3.14.9" cache: "pip" - name: Fetch all history for all tags and branches @@ -32,15 +45,45 @@ jobs: - name: Install doc dependencies run: | python -m pip install --upgrade "pip>=26.2.2" "certifi>=2026.10.19" + + if [ -f requirements.txt ]; then + echo "Found requirements.txt — installing project dependencies" + pip install -r requirements.txt + else + echo "No requirements.txt found, skipping" + fi + pip install sphinx>=7.0 pydata-sphinx-theme>=0.15 \ sphinx-autodoc-typehints myst-parser>=2.0 pip install --no-deps -e . - name: Build HTML docs - run: sphinx-build -b html docs docs/_build/html + run: sphinx-build -b html docs docs/_build/html --keep-going + # -W turns warnings into errors so broken refs/syntax fail the PR check + # --keep-going shows all warnings at once instead of stopping at the first - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0 + - name: Setup Pages + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 + + - name: Upload artifact + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: docs/_build/html + path: docs/_build/html + + deploy: + # Only deploy on pushes to main, never on PRs (including PRs from forks) + if: github.repository == 'ARM-DOE/Adapt' && github.event_name == 'push' && github.ref == 'refs/heads/main' + needs: build + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1