|
| 1 | +name: Docs GitHub Pages Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - master |
| 8 | + paths: |
| 9 | + - "docs/**" |
| 10 | + - "mkdocs.yml" |
| 11 | + - "docs/requirements-mkdocs.txt" |
| 12 | + - "scripts/run-mkdocs.js" |
| 13 | + - "package.json" |
| 14 | + - "package-lock.json" |
| 15 | + - "README.md" |
| 16 | + - ".github/workflows/docs-github-pages-publish.yml" |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + git_ref: |
| 20 | + description: "Branch, tag, or commit to publish from (rollback)" |
| 21 | + required: false |
| 22 | + type: string |
| 23 | + site_url: |
| 24 | + description: "MkDocs site_url override" |
| 25 | + required: false |
| 26 | + default: "https://jacobinwwey.github.io/NoteConnection/" |
| 27 | + type: string |
| 28 | + base_path: |
| 29 | + description: "MkDocs base path override" |
| 30 | + required: false |
| 31 | + default: "/NoteConnection/" |
| 32 | + type: string |
| 33 | + |
| 34 | +permissions: |
| 35 | + contents: read |
| 36 | + pages: write |
| 37 | + id-token: write |
| 38 | + |
| 39 | +concurrency: |
| 40 | + group: docs-github-pages |
| 41 | + cancel-in-progress: false |
| 42 | + |
| 43 | +env: |
| 44 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" |
| 45 | + |
| 46 | +jobs: |
| 47 | + verify-diataxis-map: |
| 48 | + name: verify-diataxis-map |
| 49 | + runs-on: ubuntu-latest |
| 50 | + |
| 51 | + steps: |
| 52 | + - name: Checkout repository |
| 53 | + uses: actions/checkout@v5 |
| 54 | + with: |
| 55 | + ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.git_ref != '' && github.event.inputs.git_ref || github.ref }} |
| 56 | + lfs: false |
| 57 | + |
| 58 | + - name: Setup Node.js |
| 59 | + uses: actions/setup-node@v5 |
| 60 | + with: |
| 61 | + node-version: "20" |
| 62 | + cache: "npm" |
| 63 | + |
| 64 | + - name: Install dependencies |
| 65 | + run: npm ci |
| 66 | + |
| 67 | + - name: Verify Diataxis mapping governance |
| 68 | + run: npm run docs:diataxis:check |
| 69 | + |
| 70 | + build-site: |
| 71 | + name: build-site |
| 72 | + runs-on: ubuntu-latest |
| 73 | + needs: verify-diataxis-map |
| 74 | + |
| 75 | + steps: |
| 76 | + - name: Checkout repository |
| 77 | + uses: actions/checkout@v5 |
| 78 | + with: |
| 79 | + ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.git_ref != '' && github.event.inputs.git_ref || github.ref }} |
| 80 | + lfs: false |
| 81 | + |
| 82 | + - name: Setup Python |
| 83 | + uses: actions/setup-python@v6 |
| 84 | + with: |
| 85 | + python-version: "3.12" |
| 86 | + cache: "pip" |
| 87 | + cache-dependency-path: docs/requirements-mkdocs.txt |
| 88 | + |
| 89 | + - name: Install MkDocs dependencies |
| 90 | + run: pip install -r docs/requirements-mkdocs.txt |
| 91 | + |
| 92 | + - name: Resolve MkDocs runtime URL config |
| 93 | + shell: bash |
| 94 | + run: | |
| 95 | + SITE_URL="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.site_url || '' }}" |
| 96 | + BASE_PATH="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.base_path || '' }}" |
| 97 | + if [ -z "${SITE_URL}" ]; then |
| 98 | + SITE_URL="https://jacobinwwey.github.io/NoteConnection/" |
| 99 | + fi |
| 100 | + if [ -z "${BASE_PATH}" ]; then |
| 101 | + BASE_PATH="/NoteConnection/" |
| 102 | + fi |
| 103 | + echo "MKDOCS_SITE_URL=${SITE_URL}" >> "$GITHUB_ENV" |
| 104 | + echo "MKDOCS_BASE_PATH=${BASE_PATH}" >> "$GITHUB_ENV" |
| 105 | + echo "MKDOCS_DOCS_HOST=https://jacobinwwey.github.io/" >> "$GITHUB_ENV" |
| 106 | + echo "site_url=${SITE_URL}" >> "$GITHUB_OUTPUT" |
| 107 | + echo "base_path=${BASE_PATH}" >> "$GITHUB_OUTPUT" |
| 108 | +
|
| 109 | + - name: Build docs site |
| 110 | + run: mkdocs build --config-file mkdocs.yml |
| 111 | + |
| 112 | + - name: Setup GitHub Pages |
| 113 | + uses: actions/configure-pages@v5 |
| 114 | + |
| 115 | + - name: Upload Pages artifact |
| 116 | + uses: actions/upload-pages-artifact@v4 |
| 117 | + with: |
| 118 | + path: build/mkdocs-site |
| 119 | + |
| 120 | + deploy-site: |
| 121 | + name: deploy-site |
| 122 | + runs-on: ubuntu-latest |
| 123 | + needs: build-site |
| 124 | + environment: |
| 125 | + name: github-pages |
| 126 | + url: ${{ steps.deployment.outputs.page_url }} |
| 127 | + |
| 128 | + steps: |
| 129 | + - name: Deploy to GitHub Pages |
| 130 | + id: deployment |
| 131 | + uses: actions/deploy-pages@v4 |
0 commit comments