|
| 1 | +on: |
| 2 | + workflow_call: |
| 3 | + |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + |
| 9 | + steps: |
| 10 | + - name: Avoid git conflicts when tag and branch pushed at same time |
| 11 | + if: github.ref_type == 'tag' |
| 12 | + run: sleep 60 |
| 13 | + |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v5 |
| 16 | + with: |
| 17 | + # Need this to get version number from last tag |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Install system packages |
| 21 | + run: sudo apt-get install graphviz |
| 22 | + |
| 23 | + - name: Install uv |
| 24 | + uses: astral-sh/setup-uv@v7 |
| 25 | + |
| 26 | + - name: Build docs |
| 27 | + run: uv run --locked tox -e docs |
| 28 | + |
| 29 | + - name: Remove environment.pickle |
| 30 | + run: rm build/html/.doctrees/environment.pickle |
| 31 | + |
| 32 | + - name: Upload built docs artifact |
| 33 | + uses: actions/upload-artifact@v4 |
| 34 | + with: |
| 35 | + name: docs |
| 36 | + path: build |
| 37 | + |
| 38 | + - name: Sanitize ref name for docs version |
| 39 | + run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV |
| 40 | + |
| 41 | + - name: Move to versioned directory |
| 42 | + run: mv build/html .github/pages/$DOCS_VERSION |
| 43 | + |
| 44 | + - name: Write switcher.json |
| 45 | + run: python .github/pages/make_switcher.py --add $DOCS_VERSION ${{ github.repository }} .github/pages/switcher.json |
| 46 | + |
| 47 | + - name: Publish Docs to gh-pages |
| 48 | + if: github.ref_type == 'tag' || github.ref_name == 'main' |
| 49 | + # We pin to the SHA, not the tag, for security reasons. |
| 50 | + # https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions |
| 51 | + uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 |
| 52 | + with: |
| 53 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + publish_dir: .github/pages |
| 55 | + keep_files: true |
0 commit comments