Using Git actions I automatically rebuild and deploy this website. There are some other systems that take in my changes and publish them to the contents/posts part of Hugo, and then git actions rebuilds the site and deploys the static pages.

Here’s the git actions ( running on Gitea )


name: Deploy hugo
run-name: Deploy hugo
on: [push]

jobs:
  Explore-Gitea-Actions:
    runs-on: ubuntu-latest
    steps:
      - name: insecure
        run: |
          git config --global http.sslVerify "false"

      - name: Check out repository code
        uses: actions/checkout@v4
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
        env:
          GIT_SSL_VERIFY=0

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v3
        with:
          hugo-version: '0.143.1'
          # extended: true

      - name: Build
        run: hugo --gc --minify

      - name: Commit changes
        run: |
          export GIT_SSL_VERIFY=0
          git config --global user.name 'Your Name'
          git config --global user.email 'your-username@users.noreply.github.com'
          git add .
          git commit -am "Automated"
          git push
      
      - name: rsync deployments
        uses: burnett01/rsync-deployments@7.0.2
        with:
          switches: -avzr --delete 
          path: public/
          remote_path: /var/www/html/
          remote_host: vps.localdomain
          remote_port: 22
          remote_user: remote_user
          remote_key: ${{ secrets.DEPLOY_KEY }}

Breakdown

Section name ‘insecure’ This section is needed because I’m running a self hosted Gitea server which is using a self signed certificate. My Git actions runner does not have this CA, so I must allow insecure connections. If you’re using http, or github then you probably won’t need this

Section name ‘Check out repository code’ The usual block to download the code

Section name ‘Setup Hugo’ I’m using a git actions module developed by someone to download the packages needed for hugo build. The version is set to the latest to keep it aligned with what I tested

Section name’Build’ Following the Hugo documentation this is how we build the website. This generates the files to /public

Section name ‘Commit changes’ To keep git up to date with the public folder I publish these changes. This block will add anything that has changed, even outside the public folder

Section name ‘rsync deployments’ Using someone elses module again, for rsync, I upload the changed files to my VPS. The SSH private key has been added to my Gitea secrets and the public section has been added to the VPS’s known hosts.