Files
DeepTutor/docs/DEPLOYMENT.md
2026-12-01 07:49:10 -05:00

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:

  1. Detach deeptutor.info from the legacy landing Worker in Cloudflare (keep eduhub.deeptutor.info and Email Routing DNS records intact).
  2. Update pattern in docs/wrangler.toml to deeptutor.info and set DOCS_SITE=https://deeptutor.info in the docs-production environment (and docs/astro.config.mjs).
  3. 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.