Deploy MkDocs to GitHub Pages #48
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 MkDocs to GitHub Pages | |
| on: | |
| workflow_run: | |
| workflows: ["Test"] | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| check-docs-changed: | |
| name: Check Docs Changes | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.event_name == 'workflow_dispatch' || | |
| github.event.workflow_run.conclusion == 'success' | |
| outputs: | |
| docs_changed: ${{ steps.filter.outputs.docs }} | |
| head_sha: ${{ steps.get-sha.outputs.sha }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| ref: ${{ github.event.workflow_run.head_sha || github.sha }} | |
| - name: Get SHA | |
| id: get-sha | |
| run: echo "sha=${{ github.event.workflow_run.head_sha || github.sha }}" >> $GITHUB_OUTPUT | |
| - name: Check if docs changed | |
| id: filter | |
| uses: dorny/paths-filter@v3 | |
| with: | |
| filters: | | |
| docs: | |
| - 'docs/**' | |
| - 'mkdocs.yml' | |
| build: | |
| name: Build Website | |
| needs: check-docs-changed | |
| if: needs.check-docs-changed.outputs.docs_changed == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.check-docs-changed.outputs.head_sha }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install uv | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install uv | |
| - name: Install dependencies | |
| run: | | |
| uv sync --frozen | |
| - name: Build MkDocs | |
| run: | | |
| uv run mkdocs build --verbose --clean --strict | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./site | |
| deploy: | |
| name: Deploy to GitHub Pages | |
| needs: [check-docs-changed, build] | |
| if: > | |
| needs.check-docs-changed.outputs.docs_changed == 'true' && | |
| (github.event_name == 'workflow_dispatch' || | |
| github.event.workflow_run.head_branch == 'main') | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: "github-pages" | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |