Deploy Docs to GitHub Pages #16
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: Deploy Docs to GitHub Pages | |
| on: | |
| push: | |
| branches: [main] | |
| # Below will ensure this only runs when the website's contents changed | |
| paths: | |
| - 'SlicerCART/docs/_source/**' | |
| workflow_dispatch: | |
| inputs: | |
| artifact_website: | |
| description: "Save the website as an artifact to review?" | |
| type: choice | |
| options: | |
| - "Yes" | |
| - "No" | |
| default: "Yes" | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Miniconda | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| miniforge-version: latest # Use MiniForge to avoid a potential lawsuit | |
| environment-file: SlicerCART/docs/environment.yml | |
| conda-remove-defaults: true # So we don't get sued by Anaconda | |
| auto-activate-base: false # Don't load the default "test" environment by default... | |
| activate-environment: slicercart_docs # ... load the one defined in the `environment.yml` instead | |
| - name: Build Website Files | |
| run: | | |
| # Enter the documentation path | |
| cd SlicerCART/docs | |
| # TEMPORARY: Print the current prefix for debugging sake | |
| echo "$CONDA_PREFIX" | |
| # Rebuild the website w/ Sphinx | |
| sphinx-build source/ build/ | |
| - name: Deploy to GitHub Pages | |
| # Only update the official website if this was a change to 'main' | |
| # TODO: Update when a proper release management system is made | |
| if: github.event_name == 'push' | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| # Directory below is built in the prior step | |
| publish_dir: ./SlicerCART/docs/_build | |
| publish_branch: gh-pages | |
| force_orphan: true | |
| - name: Save Website as Artifact | |
| # Only save the files as an artifact if requested | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.artifact_website == 'Yes' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: built_website | |
| path: ./SlicerCART/docs/_build |