Skip to content

Instantly share code, notes, and snippets.

@danielricecodes
Created October 7, 2014 20:56
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 danielricecodes/3cd86f05b53c4753c502 to your computer and use it in GitHub Desktop.
Save danielricecodes/3cd86f05b53c4753c502 to your computer and use it in GitHub Desktop.
Boilerplate Deploy Rake File
namespace :deploy do
desc "Deploy, migrate and restart production"
task :production do
Bundler.with_clean_env do
puts `git push origin master`
puts `git push production master`
puts `heroku pgbackups:capture DATABASE_URL --expire --app <app_name>`
puts `heroku run rake db:migrate --app <app_name>`
puts `heroku restart --app <app_name>`
puts '==> Ping the app to spin up dynos. <=='
puts `curl https://<app_name>.herokuapp.com > /dev/null 2> /dev/null`
end
end
desc "Deploy, migrate and restart staging"
task :staging do
Bundler.with_clean_env do
puts `git push origin staging`
puts `git push staging staging:master`
puts `heroku pgbackups:capture DATABASE_URL --expire --app staging-<app_name>`
puts `heroku run rake db:migrate --app staging-<app_name>`
puts `heroku restart --app staging-<app_name>`
puts '==> Ping the app to spin up dynos. <=='
puts `curl https://staging-<app_name>.herokuapp.com > /dev/null 2> /dev/null`
end
end
desc 'Safe deploy both staging and production together'
task :both do
Rake::Task['deploy:staging'].invoke
Rake::Task['deploy:production'].invoke
end
namespace :production do
desc 'Quick Deploy to Production, without running migrations.'
task :quick do
Bundler.with_clean_env do
puts `git push origin master`
puts `git push production master`
end
end
end
namespace :staging do
desc 'Quick Deploy to Staging, without running migrations.'
task :quick do
Bundler.with_clean_env do
puts `git push origin staging`
puts `git push staging staging:master`
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment