Automating Reefpoints


Partner & Developer

Dan McClain

We have a healthy mix of developers and designers, plus a project manager and office manager. This results in a group of people with varying degress of command line expertise. To make it easier to write blog posts, I added instructions to create a blog post using only GitHub.

This made it super easy for anyone to create a new blog post, have people review it, but one piece was missing: making it easy for people to publish their article once it was reviewed. Well, I solved that problem today with Travis-CI and a little bit of bash script.

The first step required was to script the publishing of our blog. We already use middleman-gh-pages, which makes publishing as easy as rake publish. I created the following script:

#!/usr/bin/env bash

set -e

git config --global ""
git config --global "sockothesock"

# This specifies the user who is associated to the GH_TOKEN

# sending output to /dev/null to prevent GH_TOKEN leak on error
git remote rm origin
git remote add origin https://${USER}:${GHTOKEN} &> /dev/null

bundle exec rake publish

echo -e "Done\n"

middleman-gh-pages is smart in that it figures out your GitHub remote based on the origin, so what we did is update the origin to use a GitHUb OAuth token that allows writing to public repos. We store the OAuth token in the environment variable GHTOKEN, which we encrypt in our travis.yml:

language: ruby
sudo: false
cache: bundler
- 2.0.0
  - master
script: "./ &> /dev/null"
  secure: eAyjmkDKLbXnGvC75KRNVLoAr6WE7ldT6JGOzOKOfQ9WxhEFgzAXoKZVO4mX4DfDfJbZbCyFmxKqALXGXjaBKwU2eQKeq1g4svBnxGPHmOKFMfVjkSCFag0bppE2JK9VXn70lVYFh8kJHavHgQ2pRYlSb78WfmUKbbB9PSH/rSE=
    secure: o2ksyDNq6Ea2oHUbUpgICYHAUdZ0QgHSQNqgn/gginNyPYAd2MtS2h7iXVrzSgeXDSNi6WpAvAeOcUnzpA6h6oBkl0YvUTaXJs50IepWfAE4UZPwX9ZFfV8YiwnOCU9ByUTU2L9qeq83W3LuDYY7j6xZJjP5KMLC78TqTKy5pd8=

I also added a Slack notification so that people can see when new blog posts get published. The last thing I did was go into the Travis-CI setting and turned off the option to build Pull Requests, as that would publish articles before they were merged. I accidentally leaked the OAuth Token in the Travis logs (that’s why the script step is redirecting output to /dev/null).

In the end, it was really simple to automate the publication of our blog. It has the added bonus of publishing corrections to the blog when anyone’s pull request is merged.

Narwin holding a press release sheet while opening the DockYard brand kit box