Hugo and Bitrise

January 29, 2017

I’ve been playing with Hugo, a static website generator. I have never particularly enjoyed creating websites in HTML, and never found a builder that didn’t quickly annoy. Hugo appeals to my need for separation whilst offering a lovely geeky feel to website and blog creation.

I’m currently in love with Bitrise. It seems to require more tinkering than buddybuild but offers more power and flexibility. It also supports Xamarin projects, which buddybuild doesn’t.

Bitrise is designed to build iOS and Android apps. However it’s ability to modify and define your own workflows allows you to build other kinds of projects (if you don’t mind a little scripting). I’ve setup a Bitrise project which detects a push to my website git repo, builds the Hugo website and then uploads to my web server.

The Bitrise workflow editor generates a YAML file. Here’s the one which builds and deploys appsonthemove.com:

---
format_version: 1.3.1
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
trigger_map:
- push_branch: "*"
  workflow: primary
- pull_request_source_branch: "*"
  workflow: primary
workflows:
  primary:
    steps:
    - activate-ssh-key@3.1.1:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@3.4.1: {}
    - script@1.1.3:
        title: Build site and upload
        inputs:
        - content: |-
            #!/bin/bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            brew install hugo

            hugo

            cd public

            scp -r * matt@myserverip:/var/www/appsonthemove.com/public_html/
        - is_debug: 'yes'
        - working_dir: "$BITRISE_SOURCE_DIR"

Simple to setup and seems to work great. I want to expand it eventually to build draft blog posts to a staging area so I can preview before going live. Hugo + Bitrise are a great solution for appsonthemove.com in 2017.

comments powered by Disqus