Skip to content

Instantly share code, notes, and snippets.

@szimek
Forked from rtomayko/notify.rb
Created March 22, 2010 11:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szimek/340008 to your computer and use it in GitHub Desktop.
Save szimek/340008 to your computer and use it in GitHub Desktop.
Alert Campfire of a Capistrano deploy
require 'httparty'
require 'json'
class Campfire
include HTTParty
base_uri 'http://your_domain.campfirenow.com'
basic_auth 'your_auth_token', 'whatever'
headers "Content-Type" => "application/json"
def self.notify(body)
post('/room/1/speak.json', :body => { :message => { :body => body }}.to_json)
end
end
require File.expand_path('../campfire', __FILE__)
namespace :notify do
desc 'Alert Campfire of a deploy'
task :campfire do
branch_name = branch.split('/', 2).last
deployer = ENV["USER"]
deployed = capture("cd #{previous_release} && git rev-parse HEAD")[0,7]
deploying = capture("cd #{current_release} && git rev-parse HEAD")[0,7]
compare_url = "#{source_repo_url}/compare/#{deployed}...#{deploying}"
Campfire.notify(
"#{deployer} deployed " +
"#{branch_name} (#{deployed}..#{deploying}) to #{rails_env} " +
"with `cap #{ARGV.join(' ')}` (#{compare_url})"
)
end
end
after "deploy:symlink", "notify:campfire"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment