Skip to content

Instantly share code, notes, and snippets.

@vindia
Created March 20, 2012 08:54
Show Gist options
  • Save vindia/2133015 to your computer and use it in GitHub Desktop.
Save vindia/2133015 to your computer and use it in GitHub Desktop.
Campfire Notification for Capistrano deploys
namespace :campfire do
desc "Notify deploy"
task :notify do
room_id = 123456 # Room ID for the Campfire Room you want this notification to appear in
token = ENV['CAMPFIRE_TOKEN'] || 'YOUR_CAMPFIRE_TOKEN' # Enter your campfire token here
if (token == 'YOUR_CAMPFIRE_TOKEN')
user_name_is = `whoami` + ' is'
else
user_name_is = "I am"
end
message = "#{user_name_is} deploying frontend to live!"
begin
request = Net::HTTP::Post.new("/room/#{room_id}/speak.json", 'Content-Type' => 'application/json')
request.body = "{\"message\":{\"type\":\"TextMessage\",\"body\":\"#{message}\"}}"
request.basic_auth token, 'x'
http = Net::HTTP.new("your_account.campfirenow.com", 443)
http.use_ssl = true
http.request(request)
rescue SocketError
return false
end
end
end
@suweller
Copy link

use git config user.name instead of whoami ;-)

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