Skip to content

Instantly share code, notes, and snippets.

@mperham
Created February 14, 2012 22:39
Show Gist options
  • Save mperham/1831203 to your computer and use it in GitHub Desktop.
Save mperham/1831203 to your computer and use it in GitHub Desktop.
Campfire deploy announcements
# 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"
@rkh
Copy link

rkh commented Feb 14, 2012

Shell out to curl? How will this EVAR SCALE? :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment