Skip to content

Deploy

Deploy #68

Workflow file for this run

name: Deploy
# Publishes both halves of the site from the same commit: the Astro site to
# GitHub Pages and the Cloudflare Worker serving /v1/*. They deploy in parallel
# rather than in sequence - an Astro build failure should not hold back the API,
# and vice versa - so both regenerate the dataset independently.
#
# Note this workflow is also started explicitly by update-db.yml: pushes made
# with GITHUB_TOKEN do not raise `push` events, so its auto-commit cannot rely
# on the trigger below.
on:
push:
branches: [main]
workflow_dispatch:
# Serialize deploys: two quick merges must not race their wrangler/Pages
# uploads, or an older dataset can land last and stay live.
concurrency:
group: deploy
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 11
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'pnpm'
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: |
pnpm install
bun install
- name: Install site workspace dependencies
working-directory: ./site
run: pnpm install
- name: Generate database
run: pnpm generate-db
- name: Build site
working-directory: ./site
run: pnpm run build
# The class pages are generated MDX that is not tracked in git, so a
# generator that skipped or died halfway no longer breaks the build by
# itself - it just produces a smaller site. Compare what was built
# against the class count the generator recorded in index.json.
- name: Check every class page was built
working-directory: ./site
run: |
expected=$(jq -r '.total' public/db/index.json)
built=$(find dist/classes -mindepth 2 -maxdepth 2 -name index.html | wc -l)
echo "class pages built: $built (expected $expected)"
if [ "$built" != "$expected" ]; then
echo "::error::class page count mismatch - generation was skipped or partial"
exit 1
fi
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./site/dist
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
deploy-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 11
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'pnpm'
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: |
pnpm install
bun install
- name: Generate database
run: pnpm generate-db
- name: Deploy worker
run: pnpm api:deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}