Skip to content

Deploy Docs

Deploy Docs #5

Workflow file for this run

name: Deploy Docs
# Deploys the docs site from a ref of this repository -- main by default.
#
# The docs app is a website, not something anyone installs. It builds against
# compiled @text-to-cad/core exports, built through the root npm workspace. It
# needs the shared source tree and root lockfile, which every ref
# of main is. Releases pass the release commit itself, which carries the bumped
# VERSION and the stamped apps/docs/package.json the site header reads. To
# redeploy a past release, pass its tag (`v0.5.0`; bare `0.4.28` before 0.5.0).
on:
workflow_dispatch:
inputs:
ref:
description: Ref to deploy — main, or a release tag (v0.5.0).
required: true
default: main
type: string
workflow_call:
inputs:
ref:
description: Source ref to deploy.
required: true
type: string
permissions:
contents: read
concurrency:
group: deploy-docs
cancel-in-progress: false
jobs:
deploy:
name: Deploy docs app
runs-on: ubuntu-latest
steps:
- name: Check out deploy ref
uses: actions/checkout@v7
with:
ref: ${{ inputs.ref }}
persist-credentials: false
# A tag from before main carried the source tree has neither, and the
# failure would otherwise surface as an opaque module-resolution error
# deep in `next build`.
- name: Check this ref can build the docs site
run: |
missing=""
[ -d apps/docs ] || missing="$missing apps/docs/"
[ -d packages/core/src ] || missing="$missing packages/core/src"
if [ -n "$missing" ]; then
echo "This ref cannot build the docs site; missing:$missing" >&2
echo "This looks like a publish commit from before main carried apps/ and packages/." >&2
echo "Deploy main, or a release tag from after the cutover." >&2
exit 1
fi
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: "22"
- name: Install Vercel CLI
run: npm install --global vercel@50.28.0
- name: Deploy docs app to Vercel production
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_DOCS_PROJECT_ID: ${{ secrets.VERCEL_DOCS_PROJECT_ID }}
run: |
for name in VERCEL_TOKEN VERCEL_ORG_ID VERCEL_DOCS_PROJECT_ID; do
if [ -z "${!name:-}" ]; then
echo "Missing GitHub Actions secret: $name" >&2
exit 1
fi
done
urls="https://www.texttocad.dev https://texttocad.dev"
# A ref with the analytics API (apps/docs/src/app/v1) is checked through api.texttocad.dev's
# health too: a 503 while the project's DATABASE_URL or CRON_SECRET is missing (both live in
# the Vercel project, never here) or its database cannot take a batch fails the deploy. An
# older ref -- a past release redeployed -- has no API, and deploys as it always did.
if [ -d apps/docs/src/app/v1 ]; then
urls="$urls https://api.texttocad.dev/v1/health"
fi
# cadgen's version feed, on refs that serve it.
if [ -f apps/docs/src/lib/api/versions.mjs ]; then
urls="$urls https://api.texttocad.dev/v1/versions"
fi
scripts/github-workflows/deploy-vercel-app.sh \
--label "Docs app" \
--project-id "$VERCEL_DOCS_PROJECT_ID" \
--public-urls "$urls"