Skip to content

Commit a69fea3

Browse files
Paul Mulliganclaude
andcommitted
ci: build and deploy docs site to Cloudflare Pages
Builds on PRs touching docs/**; deploys dist/ to the claudius-docs Pages project on pushes to main. Needs CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID repo secrets plus a one-time pages project create (documented in docs/README.md). Also keeps docs/package.json version in sync via release-please. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent eaea36b commit a69fea3

3 files changed

Lines changed: 128 additions & 1 deletion

File tree

.github/workflows/docs.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "docs/**"
8+
- ".github/workflows/docs.yml"
9+
pull_request:
10+
branches: [main]
11+
paths:
12+
- "docs/**"
13+
- ".github/workflows/docs.yml"
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
build:
22+
name: Build Docs
23+
runs-on: ubuntu-latest
24+
defaults:
25+
run:
26+
working-directory: docs
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- uses: pnpm/action-setup@v4
31+
with:
32+
version: 10
33+
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: 22
37+
cache: pnpm
38+
cache-dependency-path: docs/pnpm-lock.yaml
39+
40+
- name: Install dependencies
41+
run: pnpm install --frozen-lockfile
42+
43+
- name: Build (includes Pagefind index)
44+
run: pnpm build
45+
46+
- uses: actions/upload-artifact@v4
47+
with:
48+
name: docs-dist
49+
path: docs/dist
50+
51+
deploy:
52+
name: Deploy to Cloudflare Pages
53+
# Deploys need the CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID repo
54+
# secrets, and a one-time `wrangler pages project create claudius-docs`.
55+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
56+
needs: build
57+
runs-on: ubuntu-latest
58+
permissions:
59+
contents: read
60+
deployments: write
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- uses: actions/download-artifact@v4
65+
with:
66+
name: docs-dist
67+
path: docs/dist
68+
69+
- name: Deploy
70+
uses: cloudflare/wrangler-action@v3
71+
with:
72+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
73+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
74+
workingDirectory: docs
75+
command: pages deploy dist --project-name=claudius-docs

docs/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Claudius documentation site
2+
3+
Astro Starlight site published at
4+
[claudius-docs.pages.dev](https://claudius-docs.pages.dev). Content lives in
5+
`src/content/docs/`; `plans/` holds internal design/implementation notes and
6+
is not part of the site.
7+
8+
## Develop
9+
10+
```bash
11+
pnpm install
12+
pnpm dev # http://localhost:4321
13+
pnpm build # static build into dist/ (includes the Pagefind search index)
14+
```
15+
16+
## Deployment
17+
18+
`.github/workflows/docs.yml` builds on every PR touching `docs/**` and
19+
deploys `dist/` to the Cloudflare Pages project `claudius-docs` on pushes to
20+
`main`.
21+
22+
One-time setup (already done if the site is live):
23+
24+
1. Create the Pages project:
25+
```bash
26+
cd docs && pnpm build
27+
npx wrangler login
28+
npx wrangler pages project create claudius-docs --production-branch main
29+
npx wrangler pages deploy dist --project-name=claudius-docs
30+
```
31+
2. Add the `CLOUDFLARE_API_TOKEN` (Pages:Edit permission) and
32+
`CLOUDFLARE_ACCOUNT_ID` secrets to the GitHub repo so CI can deploy.
33+
3. Optional custom domain (e.g. `docs.claudius.dev`): Cloudflare dashboard →
34+
Pages → claudius-docs → Custom domains. Then update `site` in
35+
`astro.config.mjs` and the docs links in the root README.
36+
4. Add the docs origin to the production worker's `ALLOWED_ORIGIN`
37+
(comma-separated) so the live demo widget on the home page can chat:
38+
`ALLOWED_ORIGIN = https://pmds.info,https://claudius-docs.pages.dev`
39+
40+
## Versioned docs
41+
42+
[starlight-versions](https://github.com/HiDeoo/starlight-versions) archives a
43+
copy of the docs per major release line (currently `1.x`, browsable via the
44+
version switcher in the header). When a new major ships, add an entry to
45+
`versions` in `astro.config.mjs`; the next build snapshots the then-current
46+
docs under that slug.
47+
48+
Two authoring constraints the archiver imposes (it converts pages to MDX):
49+
50+
- No autolinks (`<https://example.com>`) — use `[text](url)` links
51+
- Raw `<`/`>` outside code spans must be valid JSX

release-please-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"changelog-path": "CHANGELOG.md",
2121
"extra-files": [
2222
{ "type": "json", "path": "widget/package.json", "jsonpath": "$.version" },
23-
{ "type": "json", "path": "worker/package.json", "jsonpath": "$.version" }
23+
{ "type": "json", "path": "worker/package.json", "jsonpath": "$.version" },
24+
{ "type": "json", "path": "docs/package.json", "jsonpath": "$.version" }
2425
]
2526
}
2627
}

0 commit comments

Comments
 (0)