I’m taking a shortcut here. With the benefit of foresight which is really hindsight, I set my runner up to run Hugo already with the label hugo. So this is really about the automation I used to do the build. I started with attempts to install Hugo using apk add with the Docker image. That was a side quest that led nowhere.
Then when I decided to split things up, it took me a while to find the right image. The official Hugo Docker image luckily it includes Node.js so it can run the checkout and upload-artifact actions.
However, you can’t do everything on the Hugo image. That means the build has to be split up into two parts. This part is only for running Hugo. Luckily, when it runs, Hugo can store the files it built (./public/) in an artifact, so it’s not too hard to get them later for uploading.
You also need to check out the right thing. For Hugo with Blowfish installed, that means checking out submodules.
If you want to avoid the shortcut and do what I really did, check out the Forgejo Actions quick start guide and build a “hello world” action first.
This is the file I ended up creating in my local repo:
on: [push]
jobs:
buildhugo:
runs-on: hugo
steps:
- run: hugo version
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: run hugo
run: hugo --gc --minify
- name: fix up RSS
run: cp ./public/index.xml ./public/rss.xml
- name: stash public files
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: public
path: ./public/ This checks out the git repo with submodules, runs hugo --gc --minify on that, copies index.xml to rss.xml because I started with Astro and didn’t want to have to migrate everyone’s links, then uploads the ./public/ directory with the name public to Forgejo’s artifact repo.
Once you’ve done that, you can:
git add .forgejo/workflows/deploy.yaml
git commit
git push originThat triggers the automation that will (first time) download the Hugo image, then build the website, then stash it in an artifact called public.
But that’s only half the story for deploy.yaml. Read about uploading to the webserver here.