Skip to content

Commit 74a242a

Browse files
authored
ci: pick the docs-preview toolchain from the PR checkout (#3081)
1 parent 148278e commit 74a242a

1 file changed

Lines changed: 27 additions & 12 deletions

File tree

.github/workflows/docs-preview.yml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
name: Docs Preview
22

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.
44
#
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.
1112
#
1213
# Required configuration:
1314
# - secrets.CLOUDFLARE_API_TOKEN (scope: Account → Cloudflare Pages → Edit)
@@ -21,6 +22,7 @@ on:
2122
- docs/**
2223
- docs_src/**
2324
- mkdocs.yml
25+
- scripts/docs/**
2426
- pyproject.toml
2527
issue_comment:
2628
types: [created]
@@ -128,17 +130,30 @@ jobs:
128130
enable-cache: false
129131
version: 0.9.5
130132

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
136148
137149
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
138150
with:
139151
name: site
140152
path: site/
141153
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
142157

143158
deploy:
144159
needs: [authorize, build]

0 commit comments

Comments
 (0)