Created
March 20, 2012 08:54
-
-
Save vindia/2133015 to your computer and use it in GitHub Desktop.
Campfire Notification for Capistrano deploys
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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use
git config user.name
instead ofwhoami
;-)