Created
February 23, 2012 00:59
-
-
Save brianjlandau/1888857 to your computer and use it in GitHub Desktop.
Heroku deploy plugin for cruise.rb
This file contains hidden or 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
| # Deploy To Heroku | |
| # | |
| class HerokuDeployer | |
| attr_accessor :campfire_config | |
| def initialize(project = nil) | |
| @campfire_config = {} | |
| end | |
| def build_finished(build) | |
| return if build.failed? | |
| deploy build | |
| end | |
| def api | |
| Tinder::Campfire.new(campfire_config[:domain], { | |
| :token => campfire_config[:token], | |
| :ssl => campfire_config[:ssl] | |
| }) | |
| end | |
| def room | |
| api.find_room_by_name(campfire_config[:room]) | |
| end | |
| def speak(msg) | |
| room.speak msg | |
| end | |
| private | |
| def deploy(build) | |
| work_path = build.project.path + "/work/" | |
| cmd = [ | |
| "cd #{work_path}", | |
| "git push heroku master >> #{build.artifacts_directory}/heroku_deploy.txt 2>&1", | |
| %Q[rvm-shell 1.9.2@pumacards -c "bundle exec heroku run rake db:migrate >> #{build.artifacts_directory}/heroku_deploy.txt"] | |
| ].join(" && ") | |
| success = system cmd | |
| notify(success, build) | |
| end | |
| def notify(success, build) | |
| if success | |
| speak "#{build.project.name} build #{build.label} has been deployed to Heroku! :+1:" | |
| else | |
| speak "#{build.project.name} build #{build.label} could not be deployed to Heroku! :-1:" | |
| end | |
| end | |
| end | |
| Project.plugin :heroku_deployer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment