name: Deploy Hugo site to Pages
on:
  push:
    branches: ["**"]
  workflow_dispatch:
permissions:
  contents: read
  id-token: write
  pages: write
concurrency:
  cancel-in-progress: true
  group: "pages"
defaults:
  run:
    shell: bash
jobs:
  build-linux:
    env:
      HUGO_VERSION: 0.119.0
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: recursive
      - name: Setup Hugo
        run: |
          wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
          && sudo dpkg -i ${{ runner.temp }}/hugo.deb
      - name: Setup Embedded Dart Sass
        run: sudo snap install dart-sass-embedded
      - id: pages
        name: Setup Pages
        uses: actions/configure-pages@v2
      - name: Build
        run: |
          cd exampleSite
          hugo --baseURL ${{ steps.pages.outputs.base_url }} --enableGitInfo --environment production --minify
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          path: ./exampleSite/public
  # build-windows:
  #   runs-on: windows-latest
  #   steps:
  #     - name: Checkout
  #       uses: actions/checkout@v3
  #       with:
  #         submodules: recursive
  #     - name: Setup Hugo
  #       run: choco install hugo-extended
  #     - name: Setup Embedded Dart Sass
  #       run: choco install dart-sass-embedded
  #     - name: Build
  #       run: |
  #         cd exampleSite
  #         echo "replace github.com/willfaught/paige => ../" >>go.mod
  #         hugo --baseURL ${{ steps.pages.outputs.base_url }} --enableGitInfo --environment production --minify
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.pages.outputs.base_url }}
    if: github.ref == 'refs/heads/master'
    needs: build-linux
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v1
