Created
February 1, 2012 15:36
-
-
Save alloy/1717566 to your computer and use it in GitHub Desktop.
Some simple Heroku deploy rake tasks.
This file contains 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
namespace :heroku do | |
namespace :deploy do | |
task :tag do | |
rev = `git rev-parse HEAD`.strip | |
if `git describe --contains #{rev} 2>&1`.include?('cannot describe') | |
version = Time.new.strftime("%Y%m%d%H%M%S") | |
sh "git tag -a heroku-#{version} -m 'Deploy version to Heroku: #{version}'" | |
sh "git push origin master" | |
sh "git push origin master --tags" | |
else | |
puts "[!] The current revision is already tagged, skipping tag creation." | |
end | |
end | |
task :no_migrations => 'heroku:deploy:tag' do | |
sh "git push heroku master" | |
sh "git push heroku master --tags" | |
end | |
desc 'Deploys *and* runs migrations (this will turn maintenance mode on)' | |
task :migrate => 'heroku:deploy:tag' do | |
Bundler.with_clean_env do | |
sh "heroku maintenance:on" | |
sh "git push heroku master" | |
sh "git push heroku master --tags" | |
sh "heroku rake db:migrate" | |
sh "heroku restart" | |
sh "heroku maintenance:off" | |
end | |
end | |
end | |
desc 'Deploys *without* running migrations' | |
task :deploy => 'heroku:deploy:no_migrations' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment