This website

Decided it was about time I made myself a website

So I have had this domain for many years mainly so I could have an email address not connected to a web service, I am currently furloughed and getting on with some of the projects that have been stacking up waiting for me and this gives me a way to document what I am getting up too starting with making this website!

What tech I am using

Work wise I don’t do anything with web technologies, so this is all new to me. A bit of research shows that static site generators are the way to go and I have picked Hugo.

Paring it with the theme Stack by CaiJimmy

One of the things I wanted to play with is CI/CD so I am using CircleCI to generate, test and deploy this site from a private GitHub repro. This turned out to make things much more complicated that I expected!

CircleCI drama

Should have probably seen this coming but paring a flashy CI service to traditional hosting proved to be less than straight forward, having to pass SSH keys into the docker container to make rsync work and dealing with git sub modules particularly tested my patience!

If anyone else stumbles across this and is struggling, this is the config I have used:

version: 2
jobs:
  build:
    docker:
      - image: cibuilds/hugo:latest
    working_directory: ~/hugo
    environment:
      HUGO_BUILD_DIR: ~/hugo/public
    steps:
      - checkout
      - run: git submodule sync && git submodule update --init
      - run: HUGO_ENV=production hugo -v -d $HUGO_BUILD_DIR
      - run: htmlproofer $HUGO_BUILD_DIR --allow-hash-href --check-html --empty-alt-ignore --disable-external
      - add_ssh_keys:
          fingerprints:
            - "76:f2:a0:60:d0:f5:f9:8d:3e:45:66:11:9c:6b:75:da"
      - run: echo $REMOTE_HOSTKEY >> ~/.ssh/known_hosts
      - deploy:
          name: deploy
          command: |
            if [ "${CIRCLE_BRANCH}" = "master" ]; then
              rsync -avcze ssh $HUGO_BUILD_DIR/ $SSH_USER@$SSH_HOST:public_html --delete-after
            else
              echo "Not master branch, not deploying"
            fi            

This needs 3 environment variables and your webserver’s SSH key configured in CircleCI

$REMOTE_HOSTKEY - Output of ssh-keyscan your-server-hostname.com

$SSH_USER - Username you can SSH onto your webserver with

$SSH_HOST - Address of your webserver