Jahed Ahmed

Long-Term Open Source Maintainance

Read more...

Automating Deployments to GitHub Pages with Middleman and Travis CI

I have a Middleman project and I want to push to GitHub Pages. How can I ease the process of making changes to the project's source files and publishing its generated static files?

Recently, I've been using Middleman to build static websites. I've dwelled into static site generators in the past but never really got into it until I started to build an actual website, the Unruly Tech site, which has multiple, often similar but slightly different pages. Copying and pasting became a chore and I didn't want to run a full blown server to compile templates due to the extra management. Hosting on GitHub Pages was enough.

Previously, working with GH Pages was simple enough. Just make changes to static assets and push them to gh-pages. But now with Middleman being the middleman, I had to make changes, compile the static files locally and then push those to gh-pages. What a chore.

Of course you could write a script to do it all in one command, but that also meant other contributors had to do the same and have a compatible environment with dependencies. That's way too much setup for a simple setup.

Build Logs from Travis CI's Web Interface

Now comes Travis CI. Travis is an automated build server, free for open source projects. It hooks into a repo and automatically runs scripts in a defined environment when something's pushed. With this, I now had a common environment to deploy from with minimal faff.

Read more...