name: Deploy Hugo site to Pages

on:
  push:
    branches: ["main"]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

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

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

defaults:
  run:
    shell: bash

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@main
        with:
          submodules: true
          fetch-depth: 0
      - name: Setup Pages
        id: pages
        uses: actions/configure-pages@main
      - uses: DeterminateSystems/nix-installer-action@main
      - uses: DeterminateSystems/flake-checker-action@main
      - name: Build with Hugo
        run: nix run .
      - name: Upload to GitHub Pages
        uses: actions/upload-pages-artifact@main
        with:
          path: ./public

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