|
| 1 | +################################################################################ |
| 2 | +# # |
| 3 | +# GITHUB ACTIONS — DEPLOY MKDOCS TO GITHUB PAGES # |
| 4 | +# # |
| 5 | +################################################################################ |
| 6 | +# |
| 7 | +# Builds the MkDocs documentation site (Material theme) and deploys it to |
| 8 | +# GitHub Pages using the official `actions/deploy-pages` action. |
| 9 | +# |
| 10 | +# Triggers: |
| 11 | +# - Push to `main` branch when docs/** files change |
| 12 | +# - Manual dispatch (workflow_dispatch) for ad-hoc deployments |
| 13 | +# |
| 14 | +# The workflow uses the "deploy to GitHub Pages via Actions" approach which |
| 15 | +# requires the repository Settings → Pages → Source to be set to |
| 16 | +# "GitHub Actions" (NOT "Deploy from a branch"). |
| 17 | +# |
| 18 | +################################################################################ |
| 19 | + |
| 20 | +name: Deploy Documentation |
| 21 | + |
| 22 | +on: |
| 23 | + push: |
| 24 | + branches: |
| 25 | + - main |
| 26 | + paths: |
| 27 | + - "docs/user_docs/**" |
| 28 | + - ".github/workflows/deploy-docs.yml" |
| 29 | + workflow_dispatch: |
| 30 | + |
| 31 | +# ----- |
| 32 | +# Allow only one concurrent deployment; skip in-progress runs for new pushes |
| 33 | +# ----- |
| 34 | +concurrency: |
| 35 | + group: "pages" |
| 36 | + cancel-in-progress: true |
| 37 | + |
| 38 | +# ----- |
| 39 | +# Permissions required for GitHub Pages deployment via Actions |
| 40 | +# ----- |
| 41 | +permissions: |
| 42 | + contents: read |
| 43 | + pages: write |
| 44 | + id-token: write |
| 45 | + |
| 46 | +jobs: |
| 47 | + # ========================================================================== |
| 48 | + # BUILD — Install dependencies and build the MkDocs static site |
| 49 | + # ========================================================================== |
| 50 | + build: |
| 51 | + runs-on: ubuntu-latest |
| 52 | + steps: |
| 53 | + # ----- |
| 54 | + # Step 1: Check out the repository |
| 55 | + # ----- |
| 56 | + - name: Checkout repository |
| 57 | + uses: actions/checkout@v4 |
| 58 | + with: |
| 59 | + fetch-depth: 0 # Full history for git-revision-date plugin (if added later) |
| 60 | + |
| 61 | + # ----- |
| 62 | + # Step 2: Set up Python |
| 63 | + # ----- |
| 64 | + - name: Set up Python |
| 65 | + uses: actions/setup-python@v5 |
| 66 | + with: |
| 67 | + python-version: "3.11" |
| 68 | + cache: "pip" |
| 69 | + cache-dependency-path: docs/user_docs/requirements-docs.txt |
| 70 | + |
| 71 | + # ----- |
| 72 | + # Step 3: Install MkDocs and dependencies |
| 73 | + # ----- |
| 74 | + - name: Install MkDocs dependencies |
| 75 | + run: pip install -r docs/user_docs/requirements-docs.txt |
| 76 | + |
| 77 | + # ----- |
| 78 | + # Step 4: Build the MkDocs site in strict mode |
| 79 | + # ----- |
| 80 | + - name: Build MkDocs site |
| 81 | + run: mkdocs build --strict |
| 82 | + working-directory: docs/user_docs |
| 83 | + |
| 84 | + # ----- |
| 85 | + # Step 5: Configure GitHub Pages |
| 86 | + # ----- |
| 87 | + - name: Setup Pages |
| 88 | + uses: actions/configure-pages@v5 |
| 89 | + |
| 90 | + # ----- |
| 91 | + # Step 6: Upload the built site as a Pages artifact |
| 92 | + # ----- |
| 93 | + - name: Upload Pages artifact |
| 94 | + uses: actions/upload-pages-artifact@v3 |
| 95 | + with: |
| 96 | + path: docs/user_docs/site |
| 97 | + |
| 98 | + # ========================================================================== |
| 99 | + # DEPLOY — Publish the built site to GitHub Pages |
| 100 | + # ========================================================================== |
| 101 | + deploy: |
| 102 | + runs-on: ubuntu-latest |
| 103 | + needs: build |
| 104 | + |
| 105 | + environment: |
| 106 | + name: github-pages |
| 107 | + url: ${{ steps.deployment.outputs.page_url }} |
| 108 | + |
| 109 | + steps: |
| 110 | + # ----- |
| 111 | + # Deploy the uploaded artifact to GitHub Pages |
| 112 | + # ----- |
| 113 | + - name: Deploy to GitHub Pages |
| 114 | + id: deployment |
| 115 | + uses: actions/deploy-pages@v4 |
0 commit comments