name: Documentation

on:
  push:
    branches: [main]

permissions:
  contents: write

concurrency:
  group: deploy-docs
  cancel-in-progress: true

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Install FFMpeg
        uses: FedericoCarboni/setup-ffmpeg@v3
      - uses: Swatinem/rust-cache@v2
        with: { shared-key: build }
      - run: cargo doc --locked --no-deps
      - uses: extractions/setup-just@v3
      - run: just timings
      - name: publish results.csv as timings.csv
        run: cp results.csv target/doc/timings.csv
      - name: make / redirect to /shapemaker/index.html
        run: |
          echo '<meta http-equiv="refresh" content="0; url=shapemaker/index.html">' > target/doc/index.html
      - name: Deploy with gh-pages
        uses: peaceiris/actions-gh-pages@v4
        with:
          keep_files: true
          force_orphan: true
          publish_dir: target/doc
          github_token: "${{ secrets.GITHUB_TOKEN }}"
