Jekyll build via github Actions

Not quite ‘professional’ yet - but, another step. We created a github Actions configuration that builds our jekyll site on commit, then packages the nginx container (from arm64) and pushes it to the github package registry.

Why we did this, instead of continuing running the build pipe on our own infrastructure? I’m looking to a way to shut down my notebook right after committing a diary update, and to be able to do that the Cx pipeline would need to run on my homecentral Raspi. So I tried to set that up, and found that the jekyll/jekyll docker image is only available to x86/amd64 architectures. I followed this finding up with some fooling around with other jekyll-related docker images that are available for arm64, but… nothing that just worked as a drop-in replacement with my setup. So it was either re-writing my setup to work with one of the arm64 jekyll images, or re-write my setup directly as a github Actions pipeline (and perhaps set myself up for public hosting on github pages, later).

Deploying at home, still

To complement the new build, I figured out how to docker-compose pull from there, to get the site image running on homecentral. No huge deal - once I figured out how to create a login token in the github settings menus. The slightly updated docker-compose.yml looks like this:

version: "3"
services:
  jekyll:
    image: docker.pkg.github.com/anotherdaniel/messages-env/messages-env:latest
    container_name: jekyll
    ports:
      - 8000:80
    restart: unless-stopped
    healthcheck:
      test: wget -q --spider http://192.168.0.10:8000 || exit 1
      interval: 1m43s
      timeout: 10s
      retries: 3

Seems to work for now! Only remaining question: how to trigger update on homecentral? Hm…

Deferred update of docker container on homecentral Raspi

Ok, this is where things become somewhat awkward, for now. We have a nice github Actions build running, and push our image to the github package registry - but still want to host it on our homecentral Raspi. With auto-updating after we pushed and built new content! The way I chose for now involves the git pre-push hook calling an ansible playbook that fire&forgets a script on the Raspi, which waits for a couple of minutes (for the github build to run), then pulls and recreates the nginx/jekyll image. The playbook can be found here, and the delayed-upgrade script looks like this:

#!/bin/bash

sleep 120
cd /home/ubuntu/dockercompose/jekyll
cat TOKEN.txt | docker login https://docker.pkg.github.com -u AnotherDaniel --password-stdin
docker-compose pull
docker-compose up -d --remove-orphans

Waymarks

  • Fix jekyll navigation links for our purposes: DONE
  • Build and update on Raspi? Solution decided on, and DONE (see above)
  • This is brittle and non-elegant. Probably move to github pages hosting soon.
  • Created my first git hook script
  • Learned about ansible - “become” means root, and the working directory of a script exec command is probably user-home (instead of the location of the executed script)