mattpolito / paratrooper

Library for creating tasks that deploy to Heroku
MIT License
107 stars 19 forks source link

Run a rake task #51

Closed kwerle closed 10 years ago

kwerle commented 10 years ago

I would like to run a rake task on heroku. In my case, I want to clear the rails cache. The rake task is trivial - but paratrooper does not seem to have an easy (documented) way to run it.

    deployment = Paratrooper::Deploy.new("amazing-production-app") do |deploy|
      ...
      deploy.add_callback(:before_setup) do |output|
        output.display("Doing my task on heroku")
        deploy.heroku.run_task("my:task")
mattpolito commented 10 years ago

@kwerle there is a way to do this but it is not exposed yet. Let me take a crack at that tomorrow. Hopefully I can come up with something that works out for you.

mattpolito commented 10 years ago

@kwerle This has been released in version 2.1. Let me know how it works out for you. There is an example in the README.

kwerle commented 10 years ago

Just in time to test on staging before monday's deployment. Assume it works unless you hear from me.

Thanks!

kwerle commented 10 years ago

Works great, but it might be worth a warning: it will only work on the +1th commit.

* Add a task
* Modify deployment to use the task
* Push
** Task fails - not found - deployment succeeds
* Push again
** Task works because it was already there.

I happened to call my task from before_warm_instance. Maybe that matters, maybe not.

mattpolito commented 10 years ago

Could be a timing issue. Hard to say without more detail. Glad it sorta works for you though.

kwerle commented 10 years ago

Turns out that I missed an API change from match_tag_to to match_tag, and maybe I was not actually deploying the new code, after all. Let's just assume that it always works, you rock, and I should pay more attention :-)

Thanks, Kurt