Created
July 22, 2011 00:04
-
-
Save boxcar/1098539 to your computer and use it in GitHub Desktop.
Boxcar deployment notifications for Ruby on Rails
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
# Boxcar Deployment Notifications for Ruby on Rails | |
# In your config/deploy.rb: | |
task :production do | |
# You will have other / more stuff here. You want to add this though: | |
set :deploy_notifications, %W[[email protected] [email protected]] | |
end | |
# Add our task hooks - notify_boxcar. | |
after "deploy", "deploy:notify_boxcar", "deploy:cleanup" | |
after "deploy:migrations", "deploy:notify_boxcar", "deploy:cleanup" | |
# And the magic happens here! | |
task :notify_boxcar, :except => { :no_release => true } do | |
rails_env = fetch(:rails_env, "production") | |
local_user = ENV['USER'] || ENV['USERNAME'] | |
begin | |
fetch(:deploy_notifications, []).each do |email| | |
puts "Notifying Boxcar user #{email} of deploy" | |
res = Net::HTTP.post_form(URI.parse("http://boxcar.io/devices/providers/J3Mjhwr8TuvzaBtc35mN/notifications"), | |
{ 'notification[from_screen_name]' => "#{application}", 'notification[message]' => "#{local_user} deployed #{rails_env}, revision #{current_revision}", | |
'notification[source_url]' => "http://#{domain}", 'email' => Digest::MD5.hexdigest(email) } | |
) | |
end | |
rescue Exception | |
end | |
puts "Boxcar notification complete." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment