Created
February 14, 2012 22:39
-
-
Save mperham/1831203 to your computer and use it in GitHub Desktop.
Campfire deploy announcements
This file contains 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
# Put this at the bottom of your config/deploy.rb | |
# Requires config file ~/.campfire.yml with your API token from | |
# your Campfire "My Info" page: | |
# | |
# token: lkjsadfsaduoi1u31oui3eh1kj2h | |
# roomid: 123456 | |
# subdomain: acmeco | |
class Room | |
attr_accessor :config | |
def initialize(cfg) | |
@config = cfg | |
end | |
def say(msg, type=:Paste) | |
`curl -i -u #{config['token']}:X -H 'Content-Type: application/xml' -d '<message><type>#{type}Message</type><body>#{msg}</body></message>' https://#{config['subdomain']}.campfirenow.com/room/#{config['roomid']}/speak.xml` | |
end | |
def paste(msg); say(msg); end | |
def text(msg); say(msg, :Text); end | |
end | |
namespace :deploy do | |
task :campfire do | |
yml = File.expand_path("~/.campfire.yml") | |
if File.exist?(yml) | |
config = YAML.load_file(yml) | |
ROOM = Room.new(config) | |
else | |
puts "Missing ~/.campfire.yml with your API token, can't announce deploys." | |
end | |
end | |
task :pre_announce do | |
deploy.campfire | |
ROOM.text "is deploying #{application} to #{stage}" if ROOM | |
end | |
task :post_announce do | |
ROOM.text "finished deploying #{application} to #{stage}" if ROOM | |
end | |
end | |
before "deploy", "deploy:pre_announce" | |
after "deploy", "deploy:post_announce" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shell out to curl? How will this EVAR SCALE? :D