Tyler Griffiths

Building Hugo sites with Sourcehut

2020-10-14

As a first post to flesh out this new blog, I thought I’d write a little about how I’ve generated it.

I have two repositories on Sourcehut, a Git and Mercurial forge I quite like. There’s a separate repository for the Hugo source and the final public repository, and I have a simple build.yml:

image: debian/buster
sources:
  - git@git.sr.ht:~tjg/tjg.sh-hugo
  - git@git.sr.ht:~tjg/tjg.sh-public
secrets:
  -  some-secret-uuid-blah-blah-blah
tasks:
  - fetch-package: sudo apt -y install hugo
  - hugo: cd tjg.sh-hugo ; hugo
  - commit: cp -r tjg.sh-hugo/public/* tjg.sh-public/ ; cd tjg.sh-public ; git config --global user.email "auto-commit@null" ; git config --global user.name "Automatic Commit" ; git checkout master ; git add . ; git commit -m "Automatic build at $(date)" ; GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git push -u origin master

A simple git push from my workstation and a git pull on the web server, and you’re done!