Giddyup! Simple web application deployment with 'git push'

Posted: Sat, 30 July 2011 | permalink | No comments

Application deployment is one of those things that just cries out for automation. Rapid and reliable deployment is incredibly valuable to developers and sysadmins alike. One-command deployment is the nirvana here; it’s a requirement of the Joel test, and I’ve never been sad when I’ve automated my deployments more and more.

There are lots of ways to automate deployment, of course; people of my background (Rails) lean towards systems like Capistrano, but other languages and environments have their own preferred options.

I am, however, a great fan of the “git push” deployment workflow popularised by Heroku. In this model, your deployment consists of a single action: performing a git push to a designated repository. This typically integrates well with existing developer workflows, and minimises the client-side dependencies that some deployment automation systems require.

While there are plenty of Google results for "git push" deployment, they’re mostly quick hacks or very tightly customised for a particular environment. Most of them require an awful lot of manual fiddling around to get working, and several are downright dangerous1.

My requirements are:

So, having found nothing out there already that fulfilled my requirements, I decided to write my own generalised deployment hook for Git, which I’ve named “Giddyup!” (exclamation mark optional, depending on how excited you are about all this).

The whole shebang grew out of a grotty application-specific hook script I was copying and modifying between a set of deployed Rack applications I work on for personal purposes; as I duplicated and hacked it up for use in more places I started to recognise what was general and what was app-specific, and once I learnt about the wonders of custom git config variables, I was away. I then spent an inordinate amount of time writing documentation and making it less of an embarrassment, and this is the end result (or the beginning, depending on how you want to look at it).

There’s no longer any Rack-specific gubbins in it; as far as I can tell it should work for pretty much anything that’s capable of being stored in a Git repository. The slightly tricky bit is to work out what to do afterwards, because that’s all application specific. Things like restarting the appserver(s) and performing database migrations. In Giddyup, all that is delegated to a couple of hook scripts that you write yourself, customised for your application.

I’m actively encouraging people who write generally-useful hook scripts to contribute them back; I’ve included a bunch of snippets that I use in my own applications already, but I’d really love it if a whole community of useful examples grew as part of this.

If it all sounds pretty good, mosey on over to my project page for Giddyup or take a look at the code on Github, especially the project README.

  1. Anyone that advocates pushing directly into a web-accessable location – leaving .git exposed for all the world to see – needs beating with a sand-filled garden hose). 


Post a comment

All comments are held for moderation; markdown formatting accepted.

This is a honeypot form. Do not use this form unless you want to get your IP address blacklisted. Use the second form below for comments.
Name: (required)
E-mail: (required, not published)
Website: (optional)
Name: (required)
E-mail: (required, not published)
Website: (optional)