|
| 1 | +name: Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: docs-${{ github.ref }} |
| 11 | + cancel-in-progress: false |
| 12 | + |
| 13 | +env: |
| 14 | + FORCE_COLOR: 1 |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Checkout repository |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Install the latest version of uv |
| 24 | + uses: astral-sh/setup-uv@v6 |
| 25 | + |
| 26 | + - name: Install dependencies |
| 27 | + run: uv sync --group doc |
| 28 | + |
| 29 | + - name: Install just |
| 30 | + uses: extractions/setup-just@v3 |
| 31 | + |
| 32 | + - name: Restore TorchIO cached data |
| 33 | + id: cache-torchio-data-restore |
| 34 | + uses: actions/cache/restore@v4 |
| 35 | + with: |
| 36 | + path: ~/.cache/torchio |
| 37 | + key: ${{ runner.os }}-torchio-data |
| 38 | + |
| 39 | + - name: Build docs |
| 40 | + run: just build-docs |
| 41 | + |
| 42 | + - name: Save TorchIO cached data |
| 43 | + if: steps.cache-torchio-data-restore.outputs.cache-hit != 'true' |
| 44 | + id: cache-torchio-data-save |
| 45 | + uses: actions/cache@v4 |
| 46 | + with: |
| 47 | + path: ~/.cache/torchio |
| 48 | + key: ${{ steps.cache-torchio-data-restore.outputs.cache-primary-key }} |
| 49 | + |
| 50 | + # Uploade to smokeshow if not on main branch |
| 51 | + - name: Upload docs to smokeshow |
| 52 | + if: github.ref != 'refs/heads/main' |
| 53 | + run: | |
| 54 | + rm ./docs/build/html/_images/*.gif |
| 55 | + rm ./docs/build/html/_images/*.png |
| 56 | + uvx smokeshow upload ./docs/build/html |
| 57 | +
|
| 58 | + # Upload to GitHub Pages if on main branch |
| 59 | + - name: Upload artifacts using actions/upload-pages-artifact |
| 60 | + if: github.ref == 'refs/heads/main' |
| 61 | + id: deployment |
| 62 | + uses: actions/upload-pages-artifact@v3 |
| 63 | + with: |
| 64 | + path: ./docs/build/html |
| 65 | + |
| 66 | + deploy: |
| 67 | + if: github.ref == 'refs/heads/main' |
| 68 | + |
| 69 | + needs: build |
| 70 | + |
| 71 | + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment |
| 72 | + permissions: |
| 73 | + pages: write # to deploy to Pages |
| 74 | + id-token: write # to verify the deployment originates from an appropriate source |
| 75 | + |
| 76 | + runs-on: ubuntu-latest |
| 77 | + |
| 78 | + # Deploy to the github-pages environment |
| 79 | + environment: |
| 80 | + name: github-pages |
| 81 | + url: ${{ steps.deployment.outputs.page_url }} |
| 82 | + |
| 83 | + steps: |
| 84 | + - name: Deploy to GitHub Pages |
| 85 | + id: deployment |
| 86 | + uses: actions/deploy-pages@v4 |
0 commit comments