|
| 1 | +name: Docs |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + # Only run on PRs that touch docs-related files to keep checks fast. |
| 7 | + paths: |
| 8 | + - "docs/**" |
| 9 | + - "README.md" |
| 10 | + - "pyproject.toml" |
| 11 | + - "deeptab/**" |
| 12 | + push: |
| 13 | + # No paths filter here: tag pushes must always build docs regardless of |
| 14 | + # which files changed in the tagged commit. Paths filters in GitHub Actions |
| 15 | + # apply to both branches and tags under the same push: block, so a tag |
| 16 | + # like v1.7.0 would be silently skipped if docs files weren't in that commit. |
| 17 | + branches: |
| 18 | + - main |
| 19 | + tags: |
| 20 | + - "v*" |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: docs-${{ github.head_ref || github.ref }} |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + build-docs: |
| 28 | + name: Build docs (Sphinx) |
| 29 | + runs-on: ubuntu-latest |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Install system dependencies |
| 35 | + run: sudo apt-get update && sudo apt-get install -y pandoc |
| 36 | + |
| 37 | + - name: Install Poetry |
| 38 | + uses: snok/install-poetry@v1 |
| 39 | + |
| 40 | + - name: Set up Python |
| 41 | + uses: actions/setup-python@v5 |
| 42 | + with: |
| 43 | + python-version: "3.10" |
| 44 | + cache: "poetry" |
| 45 | + |
| 46 | + - name: Install package |
| 47 | + run: poetry install --only main |
| 48 | + |
| 49 | + - name: Install docs dependencies |
| 50 | + run: pip install -r docs/requirements_docs.txt |
| 51 | + |
| 52 | + - name: Build Sphinx docs |
| 53 | + run: poetry run sphinx-build -b html docs/ docs/_build/html -W --keep-going |
| 54 | + |
| 55 | + # ── Triggered on push to main ────────────────────────────────────────── |
| 56 | + # RTD listens to its own webhook and publishes "latest" automatically. |
| 57 | + # The step below is informational; actual publishing is done by RTD. |
| 58 | + - name: Notify latest/dev docs will be published |
| 59 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 60 | + run: echo "Docs build succeeded. RTD will publish the 'latest' version." |
| 61 | + |
| 62 | + # ── Triggered on a release tag ───────────────────────────────────────── |
| 63 | + # RTD listens to tag pushes and publishes a versioned snapshot automatically |
| 64 | + # when "Build tags" is enabled in the RTD project settings. |
| 65 | + - name: Notify stable/versioned docs will be published |
| 66 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 67 | + run: | |
| 68 | + TAG="${GITHUB_REF_NAME}" |
| 69 | + echo "Docs build succeeded for tag ${TAG}. RTD will publish the '${TAG}' versioned docs." |
0 commit comments