Add skype notifications
This commit is contained in:
parent
afc01cfe96
commit
2e4112e6a4
2
Gemfile
2
Gemfile
|
@ -112,6 +112,8 @@ group :development do
|
||||||
gem 'binding_of_caller'
|
gem 'binding_of_caller'
|
||||||
gem 'meta_request'
|
gem 'meta_request'
|
||||||
gem 'localeapp'
|
gem 'localeapp'
|
||||||
|
gem 'skype'
|
||||||
|
gem 'ruby-dbus' if RUBY_PLATFORM =~ /linux/i
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
|
|
|
@ -411,6 +411,8 @@ GEM
|
||||||
skinny (0.2.3)
|
skinny (0.2.3)
|
||||||
eventmachine (~> 1.0.0)
|
eventmachine (~> 1.0.0)
|
||||||
thin (~> 1.5.0)
|
thin (~> 1.5.0)
|
||||||
|
skype (0.2.7)
|
||||||
|
tmp_cache
|
||||||
soundmanager-rails (1.0.0)
|
soundmanager-rails (1.0.0)
|
||||||
sprockets (2.2.2)
|
sprockets (2.2.2)
|
||||||
hike (~> 1.2)
|
hike (~> 1.2)
|
||||||
|
@ -433,6 +435,7 @@ GEM
|
||||||
time_diff (0.3.0)
|
time_diff (0.3.0)
|
||||||
activesupport
|
activesupport
|
||||||
i18n
|
i18n
|
||||||
|
tmp_cache (0.1.1)
|
||||||
treetop (1.4.15)
|
treetop (1.4.15)
|
||||||
polyglot
|
polyglot
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
|
@ -540,6 +543,7 @@ DEPENDENCIES
|
||||||
sass-rails (~> 3.2.5)
|
sass-rails (~> 3.2.5)
|
||||||
shotgun
|
shotgun
|
||||||
shoulda
|
shoulda
|
||||||
|
skype
|
||||||
soundmanager-rails
|
soundmanager-rails
|
||||||
state_machine
|
state_machine
|
||||||
therubyracer (~> 0.12.1)
|
therubyracer (~> 0.12.1)
|
||||||
|
|
|
@ -33,6 +33,9 @@ require 'puma/capistrano'
|
||||||
set :workers_count, 4
|
set :workers_count, 4
|
||||||
require './lib/recipes/resque'
|
require './lib/recipes/resque'
|
||||||
|
|
||||||
|
require './lib/recipes/skype'
|
||||||
|
set :skype_topic, 'ABF' # Skype chat topic name
|
||||||
|
|
||||||
namespace :deploy do
|
namespace :deploy do
|
||||||
task :symlink_all, :roles => :app do
|
task :symlink_all, :roles => :app do
|
||||||
run "mkdir -p #{fetch :shared_path}/config"
|
run "mkdir -p #{fetch :shared_path}/config"
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
require 'skype'
|
||||||
|
|
||||||
|
Capistrano::Configuration.instance(:must_exist).load do
|
||||||
|
Skype.config app_name: 'test-message'
|
||||||
|
set :skype_send_notification, true
|
||||||
|
|
||||||
|
namespace :skype do
|
||||||
|
task :trigger_notification do
|
||||||
|
set :skype_send_notification, true if !dry_run
|
||||||
|
end
|
||||||
|
|
||||||
|
task :configure_for_migrations do
|
||||||
|
set :skype_with_migrations, ' (with migrations)'
|
||||||
|
end
|
||||||
|
|
||||||
|
task :notify_deploy_started do
|
||||||
|
if skype_send_notification
|
||||||
|
|
||||||
|
environment_string = env
|
||||||
|
if self.respond_to?(:stage)
|
||||||
|
environment_string = "#{stage} (#{env})"
|
||||||
|
end
|
||||||
|
|
||||||
|
on_rollback do
|
||||||
|
send("Cancelled deployment of #{deployment_name} to #{environment_string}.")
|
||||||
|
send('#'*60)
|
||||||
|
end
|
||||||
|
send('#'*60)
|
||||||
|
send("Deploying #{deployment_name} to #{environment_string}#{fetch(:skype_with_migrations, '')}.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
task :notify_deploy_finished do
|
||||||
|
if skype_send_notification
|
||||||
|
|
||||||
|
environment_string = env
|
||||||
|
if self.respond_to?(:stage)
|
||||||
|
environment_string = "#{stage} (#{env})"
|
||||||
|
end
|
||||||
|
|
||||||
|
send("Finished deploying #{deployment_name} to #{environment_string}#{fetch(:skype_with_migrations, '')}.")
|
||||||
|
send('#'*60)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def send(message)
|
||||||
|
set :skype_client, Skype.chats.find { |c| c.topic == fetch(:skype_topic, '') } if fetch(:skype_client, nil).nil?
|
||||||
|
|
||||||
|
begin
|
||||||
|
skype_client.post(message)
|
||||||
|
rescue => e
|
||||||
|
puts e.message
|
||||||
|
puts e.backtrace
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def deployment_name
|
||||||
|
if fetch(:branch, nil)
|
||||||
|
name = "#{application}/#{branch}"
|
||||||
|
name += " (revision #{real_revision[0..7]})" if real_revision
|
||||||
|
name
|
||||||
|
else
|
||||||
|
application
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def message_notification
|
||||||
|
fetch(:skype_announce, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def env
|
||||||
|
fetch(:skype_env, fetch(:rack_env, fetch(:rails_env, "production")))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
before "deploy", "skype:trigger_notification"
|
||||||
|
before "deploy:update_code", "skype:notify_deploy_started"
|
||||||
|
after "deploy", "skype:notify_deploy_finished"
|
||||||
|
after "deploy:migrations", "skype:notify_deploy_finished"
|
||||||
|
end
|
Loading…
Reference in New Issue