This will be a small post; I just wanted to share a simplification, or rather finding the the essentials.
I used to deploy my Hugo website via a Continuous Integration server. In my case it was just a server I kept around, listening if a job came up, and if so it would build the site and upload it to my server. Wanna see?
image: alpine:latest
before_script:
- apk update && apk add openssh openssl rsync git
- wget https://github.com/gohugoio/hugo/releases/download/v0.31.1/hugo_0.31.1_Linux-64bit.tar.gz
- tar zxfv hugo_0.31.1_Linux-64bit.tar.gz hugo && cp ./hugo /usr/bin/hugo
- hugo version
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | ssh-add -
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo "$SSH_HOST_KEY" > ~/.ssh/known_hosts'
deploy:
script:
- git clone https://allthe.codes/maiki/heather-hugo.git themes/heather-hugo
- hugo --theme=heather-hugo --templateMetrics
- rsync -uavh --delete -e ssh public/ $HOST_USER@$HOST:$HOST_DIR
artifacts:
paths:
- public
only:
- master
This is a standard .gitlab-ci.yml
, and my workflow was amazing! I’d write something, commit it to git, and push to the remote origin, and then all this stuff would happen. What happened?
-
image: alpine:latest
- download a small, but entire OS, to build my site -
before_script:
- gotta do the things, such as update the OS image, install required packages, get the copy of Hugo I want, and then do some insane Docker stuff to get my private key loaded so it couldrsync
correctly… -
deploy:
- clone the theme, build the thing, upload it, make some copies available…?
So, what did I do all that? Easy answer: I could. I needed to know how CI works, and I know a lot about it.
I also learned about interi.org, which is a tiny, mostly text site. So I knocked 20 lines off my build.sh
:
hugo
rsync -uavh public/ interi:interi.org/
Aaaaaaaah. Doesn’t that feel better?!
But @maiki, what about automation? What about out-of-site, out-of-mind?
Damn it all, ne? What good is all that complexity, when this works, is as fast as a human needs to be, and can be shared over SMS (I would never, but still!)?