Created
May 5, 2015 07:55
-
-
Save novohispano/47b2918ece40efdfd79a to your computer and use it in GitHub Desktop.
Rake task to deploy to Heroku
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
desc "Print name" | |
task :name, [:name] do |t, arguments| | |
puts "My name is #{arguments[:name]}" | |
end | |
desc "Favorite animal" | |
task :animal, [:animal] do |t, arguments| | |
puts "My favorite animal is #{arguments[:animal]}" | |
end | |
namespace :deploy do | |
desc "Deploy application to Heroku" | |
task heroku: [:test, :push, :migrate] | |
task :test do | |
puts "Running the tests..." | |
if system("rake test:all") == false | |
puts "FAILURE: There is a problem with your tests." | |
break | |
end | |
puts "Done." | |
end | |
task :push do | |
puts "Pushing code to Heroku..." | |
if system("git push heroku heroku-ready:master") == false | |
puts "Failure: There was a problem when pushing to Heroku." | |
break | |
end | |
puts "Done." | |
end | |
task :migrate do | |
puts "Running migrations..." | |
if heroku("run rake db:migrate") == false | |
puts "FAILURE: There was a problem running your migrations." | |
break | |
end | |
puts "Done." | |
end | |
end | |
def heroku(command) | |
system("GEM_HOME='' BUNDLE_GEMFILE='' GEM_PATH='' RUBYOPT='' /usr/local/heroku/bin/heroku #{command}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment