jqr/heroku_san

Should the after_deploy hook be moved within the each_heroku_app block?

Closed this issue · 2 comments

I just started using heroku_san, but for me it makes more sense to have the heroku:deploy:after task called after each individual deploy, not all of them. In addition, I'd like to have the stage passed as an argument to the after rake task. The reason this need came up is that I like to use the figaro gem to manage config vars (makes it easy to set local and heroku).

So, in my fork, the deploy task looks like this right now.

desc "Deploys the app (default: HEAD)"
task :deploy, [:commit] => [:before_deploy] do |t, args|
  each_heroku_app do |stage|
    stage.deploy(args.commit)
    Rake::Task["heroku:deploy:after"].invoke(stage)
    Rake::Task["heroku:deploy:after"].reenable
  end
end

Any interest in this behavior for the main app?

+1

That would break the defined behavior of the after_deploy hook, which runs just once after the deploy target is run.

You can get the results you want by writing a custom deploy strategy (see HerokuSan::Deploy::Base & HerokuSan::Deploy::Rails). Deploy strategies do receive the stage, (and the commit, and the force flag).

The wiki also has a page on how to wire them up into your development environment.