Skip to content

Instantly share code, notes, and snippets.

@look
Created February 13, 2010 00:34
Show Gist options
  • Save look/303146 to your computer and use it in GitHub Desktop.
Save look/303146 to your computer and use it in GitHub Desktop.
desc "Deploy to Heroku. Pass APP=appname to deploy to a different app"
task :deploy do
require 'heroku'
require 'heroku/command'
user, pass = File.read(File.expand_path("~/.heroku/credentials")).split("\n")
heroku = Heroku::Client.new(user, pass)
cmd = Heroku::Command::BaseWithApp.new([])
remotes = cmd.git_remotes(File.dirname(__FILE__) + "/../..")
remote, app = remotes.detect {|key, value| value == (ENV['APP'] || cmd.app)}
if remote.nil?
raise "Could not find a git remote for the '#{ENV['APP']}' app"
end
`git push #{remote} master`
heroku.rake(app, "db:migrate")
heroku.restart(app)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment