name: Hugo

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: hugo-latest
    steps:
      - name: Temp fix to update hugo
        run: wget "https://github.com/gohugoio/hugo/releases/download/v0.126.3/hugo_extended_0.126.3_Linux-64bit.tar.gz" && tar xf "hugo_extended_0.126.3_Linux-64bit.tar.gz" && mv ./hugo /usr/bin/hugo && rm -f hugo_extended_0.126.3_Linux-64bit.tar.gz  LICENSE  README.md
      - name: Grab packages
        run: apt install -y rsync openssh-client
      - uses: actions/checkout@v4
        with:
          submodules: 'true'
      - name: Run build task
        run: hugo --minify
      - name: Test static page
        run: bash ${{ gitea.workspace }}/bin/test_static_page.sh
      - name: Deploy to Server
        uses: https://git.myco.systems/mirrors/ssh-deploy@main
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
          ARGS: "-rlgoDzvc -i --delete"
          SOURCE: "public/"
          REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
          REMOTE_USER: ${{ secrets.REMOTE_USER }}
          TARGET: ${{ secrets.REMOTE_TARGET }}
      - name: Running Page Speed Insights
        uses: https://github.com/JakePartusch/psi-action@v1.3
        id: drafting
        with:
          url: "https://midtowndrafting.com"
          threshold: 70
          strategy: desktop