Skip to content

Commit 5caa9dd

Browse files
committed
added starlight deployment
1 parent 73d2f35 commit 5caa9dd

2 files changed

Lines changed: 137 additions & 0 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Deploy Starlight docs to Cloudflare
2+
3+
on:
4+
push:
5+
branches: [3.x]
6+
# Only run when something the build actually consumes changes —
7+
# avoids re-deploying when the legacy docusaurus tree or unrelated
8+
# repo files are touched.
9+
paths:
10+
- "starlight/**"
11+
- "v1/**"
12+
- "v2/**"
13+
- "v3/**"
14+
- "snippets/**"
15+
- "images/**"
16+
- "assets/**"
17+
- "mp4/**"
18+
- "fonts/**"
19+
- "favicon.svg"
20+
- ".github/workflows/deploy-starlight.yml"
21+
# Manual trigger from the Actions tab.
22+
workflow_dispatch:
23+
24+
# Cancel any in-flight deploy when a newer commit lands on main.
25+
concurrency:
26+
group: deploy-starlight
27+
cancel-in-progress: true
28+
29+
jobs:
30+
deploy:
31+
name: Build & deploy
32+
runs-on: ubuntu-latest
33+
permissions:
34+
contents: read
35+
deployments: write
36+
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
41+
- name: Install pnpm
42+
uses: pnpm/action-setup@v4
43+
with:
44+
version: 10
45+
46+
- name: Set up Node
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: 22
50+
cache: pnpm
51+
cache-dependency-path: starlight/pnpm-lock.yaml
52+
53+
- name: Install dependencies
54+
working-directory: starlight
55+
run: pnpm install --frozen-lockfile
56+
57+
- name: Build site
58+
working-directory: starlight
59+
run: pnpm build
60+
61+
- name: Inject Cloudflare route into wrangler.toml
62+
# wrangler.toml ships without a [[routes]] block because wrangler
63+
# doesn't interpolate env vars there. Append one from repo vars
64+
# so the same file works for local *.workers.dev deploys and for
65+
# zone-bound CI deploys without a code change.
66+
if: vars.CF_ROUTE_PATTERN != '' && vars.CF_ZONE_NAME != ''
67+
working-directory: starlight
68+
env:
69+
CF_ROUTE_PATTERN: ${{ vars.CF_ROUTE_PATTERN }}
70+
CF_ZONE_NAME: ${{ vars.CF_ZONE_NAME }}
71+
run: |
72+
{
73+
echo ""
74+
echo "[[routes]]"
75+
echo "pattern = \"${CF_ROUTE_PATTERN}\""
76+
echo "zone_name = \"${CF_ZONE_NAME}\""
77+
} >> wrangler.toml
78+
echo "--- wrangler.toml route block ---"
79+
tail -4 wrangler.toml
80+
81+
- name: Deploy to Cloudflare Workers
82+
uses: cloudflare/wrangler-action@v3
83+
with:
84+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
85+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
86+
workingDirectory: starlight
87+
# wrangler reads ./wrangler.toml from workingDirectory and uses
88+
# the [assets] block to upload ./dist.
89+
command: deploy

starlight/wrangler.toml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#:schema node_modules/wrangler/config-schema.json
2+
3+
# Cloudflare Worker config for the Starlight docs build.
4+
#
5+
# Deployment model: Workers Static Assets (no Worker script needed).
6+
# Wrangler uploads `./dist` and serves it directly. Because every page
7+
# the build produces lives under `/docs/...` (the splash at /docs/, all
8+
# versioned content at /docs/v1/, /docs/v2/, /docs/v3/), this Worker
9+
# slots cleanly into a `/docs/*` route on a parent zone.
10+
#
11+
# Build first: pnpm --filter starlight build
12+
# Deploy: npx wrangler deploy
13+
# Local preview: npx wrangler dev
14+
#
15+
# To mount on the /docs/* subpath of an existing zone, uncomment the
16+
# [[routes]] block below and replace the pattern + zone_name with your
17+
# domain. Without routes, the Worker is reachable at its
18+
# *.workers.dev URL.
19+
20+
name = "inertiacore-docs"
21+
compatibility_date = "2026-04-13"
22+
23+
# Workers Static Assets — points at the Astro build output.
24+
# `not_found_handling = "404-page"` makes Cloudflare serve dist/404.html
25+
# for unmatched paths, which Starlight already generates.
26+
[assets]
27+
directory = "./dist"
28+
not_found_handling = "404-page"
29+
30+
# Route binding lives in CI, not here.
31+
#
32+
# Wrangler does not interpolate environment variables inside
33+
# `[[routes]]` blocks, so this file ships without one. The deploy
34+
# workflow appends a `[[routes]]` block from the `CF_ROUTE_PATTERN` and
35+
# `CF_ZONE_NAME` GitHub Actions repository variables before running
36+
# `wrangler deploy` — see .github/workflows/deploy-starlight.yml.
37+
#
38+
# Without a route, `wrangler deploy` puts this Worker on its
39+
# *.workers.dev URL, which is fine for local smoke-testing via
40+
# `npx wrangler deploy` or `npx wrangler dev`.
41+
42+
# Optional: separate dev/staging environment with its own subdomain.
43+
#
44+
# [env.staging]
45+
# name = "inertiacore-docs-staging"
46+
# [env.staging.assets]
47+
# directory = "./dist"
48+
# not_found_handling = "404-page"

0 commit comments

Comments
 (0)