Skip to content

Instantly share code, notes, and snippets.

@Olgagr
Forked from fancyremarker/heroku.rake
Last active August 29, 2015 14:08
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 Olgagr/01fd03538e575767aa72 to your computer and use it in GitHub Desktop.
Save Olgagr/01fd03538e575767aa72 to your computer and use it in GitHub Desktop.
module Heroku
module Rake
class Task
attr_accessor :name
def initialize(name)
@name = name
end
def self.[](name)
Heroku::Rake::Task.new(name)
end
def execute(options = {})
cmd = "heroku run \"rake #{name}"
cmd += "; echo \\$?\""
cmd += "#{options[:app] ? " --app #{options[:app]}" : ""}"
stdout = `#{cmd}`
$stdout.puts stdout.lines.to_a[0...-1]
exit_status = stdout.lines.to_a.last.chomp.to_i
raise "Heroku task #{name} failed with exit status #{exit_status}" unless exit_status == 0
end
end
end
end
namespace :heroku
desc "Run example task on remote Heroku"
task "example_task" do
Heroku::Rake::Task["example_task"].execute({ :app => "example-app" })
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment