Skip to content

Instantly share code, notes, and snippets.

@juandazapata
Created February 12, 2013 15:10
Show Gist options
  • Save juandazapata/4770505 to your computer and use it in GitHub Desktop.
Save juandazapata/4770505 to your computer and use it in GitHub Desktop.
Deploy task to Heroku
# Pushes to heroku origin
# Call like this:
# >> rake deploy:heroku staging
# >> rake deploy:heroku production
namespace :deploy do
task :heroku do
current_branch = `git branch --no-color | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`.gsub("\n", "").gsub("* ", "")
deploy_to = ARGV[1].try(:dup) || 'staging'
sh "git push #{deploy_to} #{current_branch}:master -f"
sh "heroku run rake db:migrate -r #{deploy_to}"
sh "echo \"Rails.cache.clear; exit\" | heroku run console -r #{deploy_to}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment