Brain Phrye

code cooking diy fiction personal photos politics reviews tools


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.

1
2
3
4
5
#!/bin/sh

set -e

make spell

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

1
2
3
4
5
6
#!/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 public/ dir is marked as an artifact 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.

1
2
3
4
5
6
7
8
9
#!/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: