Skip to content

Instantly share code, notes, and snippets.

@mertonium

mertonium/deploy.rb

Last active Oct 10, 2015
Embed
What would you like to do?
Capistrano task to notify Ratchet.io about deployment
# I am trying out Ratchet.io and I want to add their deployment notification to my
# normal capistrano deployment process. Here is my first working attempt.
# Add this task to your deploy.rb
namespace :rollbar do
task :notify, :roles => [:web] do
set :revision, `git log -n 1 --pretty=format:"%H"`
set :local_user, `whoami`
set :rollbar_token, YOUR_ACCESS_TOKEN
rails_env = fetch(:rails_env, 'production')
run "curl https://api.rollbar.com/api/1/deploy/ -F access_token=#{rollbar_token} -F environment=#{rails_env} -F revision=#{revision} -F local_username=#{local_user} >/dev/null 2>&1", :once => true
end
end
# Then add this task to your deployment flow, i.e.
after "deploy:restart", "rollbar:notify"
@brianr

This comment has been minimized.

Copy link

@brianr brianr commented Dec 4, 2012

Looks like this should have :once => true set on the run command, e.g.

  run "curl ...", :once => true

so that this task only runs once per deployment, instead of once for each app server.

@ferblape

This comment has been minimized.

Copy link

@ferblape ferblape commented Apr 17, 2013

I'd suggest use a namespace:

namespace :rollbar do
  task :notify, :roles => [:web] do
    set :revision, `git log -n 1 --pretty=format:"%H"`
    set :local_user, `whoami`
    set :rollbar_token, YOUR_ACCESS_TOKEN
    rails_env = fetch(:rails_env, 'production')
    run "curl https://api.rollbar.com/api/1/deploy/ -F access_token=#{rollbar_token} -F environment=#{rails_env} -F revision=#{revision} -F local_username=#{local_user} >/dev/null 2>&1", :once => true
  end
end
after  "deploy:restart", "rollbar:notify"
@mertonium

This comment has been minimized.

Copy link
Owner Author

@mertonium mertonium commented Jul 8, 2013

Whoa, I just saw the comments and updated the gist accordingly. Thanks @brianr & @ferblape !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.