How this blog gets deployed (part 2)

Yesterday I covered the overview of how this gets deployed. Now for the detail.

The script for testing is more aspirational than functional. It runs a spellcheck on the blog, but doesn’t die if it finds any. I’m supposed to read the output. I never do. I should though. Someday I’ll add consequences to the spellcheck run, but for now at least it tries.

#!/bin/sh

set -e

make spell

Next up is the script that does the build and deployment to pages.

#!/bin/sh

set -e

make publish BASEURL=http://kevin.pages.home/phrye.com/
mv output public

This is rather simple. It does the make publish step but does a bit to reset the base url. The resulting output/ dir is moved to publish/ to work with the gitlab pages system.

Note that this and the deploy job use a custom golang docker container. The main change is that I’ve installed and built hugo in it. There are some other tools and bits in there, but for this project it’s hugo being there that matters.

The last step is a deploy which is done by getting credentials from the Gitlab CI’s protected variables. Then it’s just a git push. The actual building of the blog is done via a git hook on the server.

#!/bin/sh

set -e

eval $(ssh-agent -s)
echo "$PRIVATE_KEY" > /ssh-id
chmod 600 /ssh-id
ssh-add /ssh-id
git push blog@phrye.com:phrye.com.git HEAD:master

There are obvious improvements to be made. Ones that come to mind:

  • The test step should fail on failures.
  • Add a link checker to a scheduled build to check for dead links.
  • Add a deploy checker to make sure the server side build job completed.