name: Deploy Docs to GitHub Pages

on:
  push:
    branches: [main]
    paths:
      - 'hindsight-docs/**'
      - '.github/workflows/deploy-docs.yml'
  workflow_dispatch:

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

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

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: 20
          cache: npm
          cache-dependency-path: package-lock.json
      - uses: astral-sh/setup-uv@v7
      - run: npm ci --workspace=hindsight-docs
      - run: uv run generate-llms-full
      - run: npm run build --workspace=hindsight-docs
        env:
          UMAMI_URL: https://analytics.hindsight.vectorize.io
          UMAMI_WEBSITE_ID: ${{ secrets.UMAMI_WEBSITE_ID }}
      - uses: actions/upload-pages-artifact@v4
        with:
          path: hindsight-docs/build
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - uses: actions/deploy-pages@v4
        id: deployment
