Skip to content

Instantly share code, notes, and snippets.

@boxcar
Created July 22, 2011 00:04
Show Gist options
  • Save boxcar/1098539 to your computer and use it in GitHub Desktop.
Save boxcar/1098539 to your computer and use it in GitHub Desktop.
Boxcar deployment notifications for Ruby on Rails
# 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[example@example.com example2@example.com]
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