name: pages

# Build the static site (tools/build-site.ts) and publish it to GitHub Pages.
# Runs on pushes to main that touch the site, and on demand. The build is
# dependency-free; benchmark numbers come from the committed
# site/data/benchmarks.json, regenerated locally with `bun run site:data`
# (CI has no ledger, so it never overwrites that data).
on:
  push:
    branches: [main]
    paths:
      - 'site/**'
      - 'tools/build-site.ts'
      - '.github/workflows/pages.yml'
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

# One live deploy at a time; don't cancel an in-flight publish.
concurrency:
  group: pages
  cancel-in-progress: false

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest
      - name: Build site
        run: bun run tools/build-site.ts
      - uses: actions/configure-pages@v6
      - uses: actions/upload-pages-artifact@v5
        with:
          path: site/dist

  deploy:
    needs: build
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - id: deployment
        uses: actions/deploy-pages@v5
