Created
August 2, 2012 18:03
-
-
Save adamlogic/3239196 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :deploy => ['heroku:push', | |
'airbrake:deploy'] | |
namespace :deploy do | |
task :migrations => ['heroku:maintenance:on', | |
'heroku:db:backup', | |
'heroku:push', | |
'heroku:db:migrate', | |
'heroku:restart', | |
'heroku:maintenance:off', | |
'airbrake:deploy'] | |
end | |
namespace :heroku do | |
HEROKU_APPS = { :production => 'teamsterapp' } | |
task :push do | |
current_branch = `git branch | grep '*' | cut -d ' ' -f 2`.strip | |
git_remote = `git remote -v | grep '#{heroku_app}.git' | grep -e push | cut -f 1 | cut -d : -f 3`.strip | |
sh "git push #{git_remote} #{current_branch}:master" | |
end | |
task :restart do | |
sh "heroku restart --app #{heroku_app}" | |
end | |
namespace :db do | |
task :backup do | |
sh "heroku pgbackups:capture --app #{heroku_app}" | |
end | |
task :migrate do | |
sh "heroku run rake db:migrate --app #{heroku_app}" | |
end | |
end | |
namespace :maintenance do | |
task :on do | |
sh "heroku maintenance:on --app #{heroku_app}" | |
end | |
task :off do | |
sh "heroku maintenance:off --app #{heroku_app}" | |
end | |
end | |
def heroku_app | |
if ENV['TO'].nil? | |
raise "You must specify which Rails environment you are deploying (use the TO=production option)." | |
end | |
HEROKU_APPS[ENV['TO'].to_sym] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment