Subscribe to the goodies

Email Address

Deploying your static site with Travis CI

Rowan–Thursday, 14 May 2015

So I know I just wrote a post about deploying your sites with Netlify, but this very website uses Travis CI for continuous deployment. There was just one minor issue that was preventing the CI/CD process running smoothly… Any Pull Requests submitted to master were deployed just the same as a commit directly to master.

At first I thought it was an issue with the configuration. Travis allows you to specify branches to run on, e.g.

So, great, it should only run on master. If you push a bunch of commits to say my_new_feature branch, no builds from Travis. Pull requests are treated a little differently though, when you submit a PR to merge that branch into master, it runs the build no matter what branch it came from.

Now this actually makes sense: test that the new feature branch is A-OK, so that it can be merged into master. The problem is we were running the deploy script on a successful build, so for this website it would, for example, publish a perfectly ‘valid’ blog post, even if it hadn’t been proofread. It was arguably a little too ambitious with the Continuous part of Continuous Delivery.

So, we’ve made some changes to the Travis setup. We’ve now removed the deploying element from the script, and separated it: