|
1 | 1 | name: Docs Preview |
2 | 2 |
|
3 | | -# Builds the mkdocs site for a PR and deploys it to Cloudflare Pages. |
| 3 | +# Builds the docs site for a PR and deploys it to Cloudflare Pages. |
4 | 4 | # |
5 | | -# Security: mkdocs executes Python from the PR (mkdocstrings imports src/mcp, |
6 | | -# `!!python/name:` directives). The build is gated by `authorize` (admin sender |
7 | | -# for auto-preview, admin/maintainer commenter for /preview-docs) and isolated |
8 | | -# from Cloudflare secrets — `build` runs PR code with no secrets and hands the |
9 | | -# static site to `deploy` via an artifact, so PR code never shares a runner |
10 | | -# with the Cloudflare token. |
| 5 | +# Security: the build executes Python from the PR (mkdocstrings imports |
| 6 | +# src/mcp, `!!python/name:` config directives run, and heads may ship their |
| 7 | +# own build scripts). The build is gated by `authorize` (admin sender for |
| 8 | +# auto-preview, admin/maintainer commenter for /preview-docs) and isolated |
| 9 | +# from Cloudflare secrets — `build` runs PR code with no secrets and hands |
| 10 | +# the static site to `deploy` via an artifact, so PR code never shares a |
| 11 | +# runner with the Cloudflare token. |
11 | 12 | # |
12 | 13 | # Required configuration: |
13 | 14 | # - secrets.CLOUDFLARE_API_TOKEN (scope: Account → Cloudflare Pages → Edit) |
|
21 | 22 | - docs/** |
22 | 23 | - docs_src/** |
23 | 24 | - mkdocs.yml |
| 25 | + - scripts/docs/** |
24 | 26 | - pyproject.toml |
25 | 27 | issue_comment: |
26 | 28 | types: [created] |
@@ -128,17 +130,30 @@ jobs: |
128 | 130 | enable-cache: false |
129 | 131 | version: 0.9.5 |
130 | 132 |
|
131 | | - - run: uv sync --frozen --group docs |
132 | | - - run: uv run --frozen --no-sync mkdocs build |
133 | | - env: |
134 | | - # Silence mkdocs-material's MkDocs 2.0 warning banner in CI logs. |
135 | | - NO_MKDOCS_2_WARNING: "1" |
| 133 | + # pull_request_target runs this workflow file from the base branch, so |
| 134 | + # the whole recipe — dependency sync included — must come from the |
| 135 | + # checkout itself: heads that ship scripts/docs/build.sh (the Zensical |
| 136 | + # toolchain) build with it; older heads, and v1.x heads previewed via |
| 137 | + # /preview-docs, still build with MkDocs. Both arms must write the site |
| 138 | + # to site/. Keep the detection in sync with build_site() in |
| 139 | + # scripts/build-docs.sh. |
| 140 | + - run: | |
| 141 | + if [ -f scripts/docs/build.sh ]; then |
| 142 | + bash scripts/docs/build.sh |
| 143 | + else |
| 144 | + uv sync --frozen --group docs |
| 145 | + # The env var silences mkdocs-material's MkDocs 2.0 warning banner. |
| 146 | + NO_MKDOCS_2_WARNING=1 uv run --frozen --no-sync mkdocs build |
| 147 | + fi |
136 | 148 |
|
137 | 149 | - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
138 | 150 | with: |
139 | 151 | name: site |
140 | 152 | path: site/ |
141 | 153 | retention-days: 1 |
| 154 | + # An empty site/ means the build arm broke its output contract; fail |
| 155 | + # here instead of surfacing as a confusing download error in deploy. |
| 156 | + if-no-files-found: error |
142 | 157 |
|
143 | 158 | deploy: |
144 | 159 | needs: [authorize, build] |
|
0 commit comments