4.3 KiB
Production docs deployment
docs.deeptutor.info serves the Astro/Starlight static build through Cloudflare Workers Static Assets. GitHub Pages serves pull request and fork previews through the docs workflow.
Build a release
Use Node.js 22 and run these commands from the repository root. Build from the release tag, with the production origin and root base.
(
set -e
python3 -X utf8 docs/scripts/check_docs.py
cd docs
npm ci
DOCS_SITE=https://docs.deeptutor.info DOCS_BASE=/ DOCS_NOINDEX=0 \
ASTRO_TELEMETRY_DISABLED=1 npm run build
cd ..
DOCS_BASE=/ python3 -X utf8 docs/scripts/check_docs.py dist
)
Astro writes the English and Chinese pages and their assets to docs/dist/.
Wrangler configuration and credentials
Production deployment uses docs/wrangler.toml (Worker deeptutor-docs, Cloudflare Workers Static Assets from ./dist). Account ID and API token stay out of git and are provided through the docs-production GitHub Environment (or your local shell for manual deploys).
| Environment variable | Purpose |
|---|---|
CLOUDFLARE_API_TOKEN |
Deploy and roll back Workers in the production Cloudflare account. Store it in the docs-production GitHub Environment for CD. |
CLOUDFLARE_ACCOUNT_ID |
Selects the account that owns the production Worker. Store it in the docs-production GitHub Environment for CD. |
Automatic deployment on Release
The deploy workflow automatically builds, validates, and deploys docs/ to Cloudflare Workers whenever a non-draft, non-prerelease GitHub Release is published. It also supports workflow_dispatch for docs-only updates. PR checks continue to run in the docs workflow without Cloudflare credentials.
To migrate the live domain from docs.deeptutor.info to deeptutor.info once the new landing site launches:
- Detach
deeptutor.infofrom the legacy landing Worker in Cloudflare (keepeduhub.deeptutor.infoand Email Routing DNS records intact). - Update
patternindocs/wrangler.tomltodeeptutor.infoand setDOCS_SITE=https://deeptutor.infoin thedocs-productionenvironment (anddocs/astro.config.mjs). - Add a Cloudflare Zone Redirect Rule:
docs.deeptutor.info/*→301 https://deeptutor.info/$1.
Deploy and verify
With the confirmed production configuration and credentials, switch to docs/ and set WRANGLER_VERSION to the exact version agreed for production.
npx --yes --package="wrangler@${WRANGLER_VERSION:?Set the approved Wrangler version}" \
wrangler deployments list --config wrangler.toml
Record the active Worker version ID before deploying.
npx --yes --package="wrangler@${WRANGLER_VERSION:?Set the approved Wrangler version}" \
wrangler deploy --config wrangler.toml
Record the release tag and the new Worker version ID. Open the English and Chinese home pages, then check a documentation page and its images or styles.
For automatic production deployment, publish a release from a tag that contains the docs and the planned docs-cd.yml. Add the workflow to the default branch before using workflow_dispatch for docs-only fixes. See GitHub Actions workflow events. PR checks and previews continue to use docs.yml without Cloudflare credentials.
Roll back
Restore the recorded previous Worker version in the Cloudflare dashboard, or run the following from docs/ with the production credentials. Set PREVIOUS_VERSION_ID to the known-good Worker version.
npx --yes --package="wrangler@${WRANGLER_VERSION:?Set the approved Wrangler version}" \
wrangler rollback "${PREVIOUS_VERSION_ID:?Set the known-good Worker version}" --config wrangler.toml
Verify both locales and reload a documentation page to check its assets. If Cloudflare no longer retains the version, rebuild from the last known-good tag and deploy that build using the confirmed production settings.
See the Cloudflare Static Assets configuration and Workers rollback procedure.