Skip to content

Instantly share code, notes, and snippets.

@gflarity
Created February 17, 2012 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gflarity/1854193 to your computer and use it in GitHub Desktop.
Save gflarity/1854193 to your computer and use it in GitHub Desktop.
simple node.js based deployment tool
//each task gets executed in parallel across each host defined, each phase is executed serially
//support for running individual phases+tasks should be easy
phase( 'web' )
.host( 'a.domain.com' )
.host( 'b.domain.com' )
.config( 'foo', [ 1, 2, 3 ] )
.task( 'checkout code',
function( c )
{
//access to info
var host = c.host;
var foo = c.config.foo;
//first we get the previous version
c.ssh( 'git show-ref --hash refs/heads/master',
function( stdout, stderr ) { c.stash.previous_version = stdout }, );
//update the code
c.ssh( 'sudo git reset --hard origin/production' );
//get new version
c.ssh( 'git show-refs --hash refs/heads/master',
function( stdout, stderr ) { c.stash.current_version = stdout } );
}
)
.task( 'restart apache', function( c ) {
var on_complete = function ( stderr, stdout, exitcode ) {
//check that exit code
};
c.ssh( 'sudo service apache restart', on_complete );
})
.task( 'email', function( c) {
//send out an email
} );
phase( 'two' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment