name: Deploy to GitHub Pages

on:
  push:
    branches: [main]
    paths: [site/**]
  workflow_dispatch:

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

concurrency:
  group: pages
  cancel-in-progress: true

jobs:
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm
          cache-dependency-path: site/package-lock.json
      - run: npm ci
        working-directory: site
      - run: npm run build
        working-directory: site
      - name: Assemble site
        run: |
          cp site/public/index.html site/dist/index.html
          cp site/public/logo.png site/dist/logo.png
          cp site/public/landing.css site/dist/landing.css
          cp site/public/og.png site/dist/og.png
          cp site/public/robots.txt site/dist/robots.txt
          cp site/public/sitemap.xml site/dist/sitemap.xml
          cp site/public/404.html site/dist/404.html
          cp site/public/CNAME site/dist/CNAME
      - uses: actions/configure-pages@v5
      - uses: actions/upload-pages-artifact@v3
        with:
          path: site/dist
      - id: deployment
        uses: actions/deploy-pages@v4
