Skip to content

Instantly share code, notes, and snippets.

@erbmicha
Created May 24, 2012 16:11
Show Gist options
  • Save erbmicha/2782474 to your computer and use it in GitHub Desktop.
Save erbmicha/2782474 to your computer and use it in GitHub Desktop.
Ruby script to more easily deploy to environments with their own branches when using capistrano-multistage
#!/usr/bin/env ruby
if ARGV.size < 2
puts "Usage: deployto <environment> <branch name>"
else
begin
env = ARGV[0]
branch = ARGV[1]
system("git checkout #{env};git merge #{branch};git push origin #{env};cap #{env} deploy:migrations;")
system("cap #{env} deploy:cleanup")
rescue
puts "Error: #{$?}"
ensure
system("git checkout #{branch}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment