captainu-chinook 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72f7231f7bab8df6d487ebbc799745ca4e07b364
4
- data.tar.gz: 613b87cdefc9d478a4cfb9114ae6474d1b3ca819
3
+ metadata.gz: 1778f8d37556f4b4a65a329c4ec0128f34074a4a
4
+ data.tar.gz: 9662d34283a768b7adade4706d5dec3919a67cc7
5
5
  SHA512:
6
- metadata.gz: 3667a63b2a5aacc28e564ee0f1bd0fcedae23eea2e0b272a31e09f71b7e06635976aead2692a6f92dbdf8afc691d296cd760ab5b320025c2e7c4a61655d77fdf
7
- data.tar.gz: d525ba3dae3bc502511f1ab3d61ed7ca2a6bc838e8bad8934801cbcd37a0094691710fa7e5e19fff55ddff7beac61bf70f0a37a984976d13348c62e77a26a816
6
+ metadata.gz: cf7b010d705aca7648b2f608996c5f40736e771d5cbee456abc4bf2170d1e4016b75479746a653d8b2a64040560b52d3c3f38324789772b7bcb1216a52742a57
7
+ data.tar.gz: 3c190f81aa55f09c2263526599ffe5b9bc477aed31e6e730b8a3ce950d80353df8e8b9fef9bdbfe6b3ed3ca8d1ab34e03966972ad099c191bdfb74c692550c6e
data/chinook.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_runtime_dependency 'capistrano', '~> 2.15.5'
21
21
  spec.add_runtime_dependency 'tinder', '~> 1.9.4'
22
+ spec.add_runtime_dependency 'slack-notifier', '~> 0.4.1'
22
23
 
23
24
  spec.add_development_dependency 'bundler', '~> 1.5'
24
25
  spec.add_development_dependency 'rake'
@@ -0,0 +1,86 @@
1
+ # Defines a task that will let a Slack channel know about a deploy.
2
+ require 'capistrano'
3
+ require 'slack-notifier'
4
+
5
+ module Chinook::Capistrano
6
+ module Slack
7
+ def self.load_into(configuration)
8
+ configuration.load do
9
+ namespace :chinook do
10
+ desc 'Lets a Slack channel know about a deploy that has begun.'
11
+ task :slack_start, except: { no_release: true } do
12
+ unless exists?(:slack_channel) && exists?(:slack_token) && exists?(:slack_team)
13
+ logger.info 'Cannot notify Slack without :slack_channel, :slack_token, and :slack_team. Skipping task.'
14
+ next
15
+ end
16
+
17
+ project_name = fetch(:project_name, application)
18
+ git_username = `git config user.name`.chomp
19
+
20
+ message = "#{git_username} started a deploy of #{project_name} to #{stage} at #{Time.now.strftime('%r %Z')}."
21
+ message = ":shipit: #{message}" if fetch(:slack_shipit)
22
+
23
+ slack = ::Slack::Notifier.new(fetch(:slack_team),
24
+ fetch(:slack_token))
25
+ slack.channel = fetch(:slack_channel)
26
+ slack.username = fetch(:slack_username)
27
+
28
+ icon = fetch(:slack_icon_url)
29
+ opts = { icon_url: icon } if icon
30
+ slack.ping message, opts
31
+ end
32
+
33
+ desc 'Lets a Slack channel know about a deploy that is rolling back.'
34
+ task :slack_rollback, except: { no_release: true } do
35
+ unless exists?(:slack_channel) && exists?(:slack_token) && exists?(:slack_team)
36
+ logger.info 'Cannot notify Slack without :slack_channel, :slack_token, and :slack_team. Skipping task.'
37
+ next
38
+ end
39
+
40
+ project_name = fetch(:project_name, application)
41
+ git_username = `git config user.name`.chomp
42
+
43
+ message = "#{git_username}'s deploy of #{project_name} to #{stage} has been rolled back at #{Time.now.strftime('%r %Z')}."
44
+ message = ":shipit: #{message}" if fetch(:slack_shipit)
45
+
46
+ slack = ::Slack::Notifier.new(fetch(:slack_team),
47
+ fetch(:slack_token))
48
+ slack.channel = fetch(:slack_channel)
49
+ slack.username = fetch(:slack_username)
50
+
51
+ icon = fetch(:slack_icon_url)
52
+ opts = { icon_url: icon } if icon
53
+ slack.ping message, opts
54
+ end
55
+
56
+ desc 'Lets a Slack channel know about a deploy that has finished.'
57
+ task :slack_end, except: { no_release: true } do
58
+ unless exists?(:slack_channel) && exists?(:slack_token) && exists?(:slack_team)
59
+ logger.info 'Cannot notify Slack without :slack_channel, :slack_token, and :slack_team. Skipping task.'
60
+ next
61
+ end
62
+
63
+ project_name = fetch(:project_name, application)
64
+ git_username = `git config user.name`.chomp
65
+
66
+ message = "#{git_username}'s deploy of #{project_name} to #{stage} finished at #{Time.now.strftime('%r %Z')}."
67
+ message = ":shipit: #{message}" if fetch(:slack_shipit)
68
+
69
+ slack = ::Slack::Notifier.new(fetch(:slack_team),
70
+ fetch(:slack_token))
71
+ slack.channel = fetch(:slack_channel)
72
+ slack.username = fetch(:slack_username)
73
+
74
+ icon = fetch(:slack_icon_url)
75
+ opts = { icon_url: icon } if icon
76
+ slack.ping message, opts
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ if Capistrano::Configuration.instance
85
+ Chinook::Capistrano::Slack.load_into(Capistrano::Configuration.instance)
86
+ end
@@ -3,4 +3,6 @@ module Chinook
3
3
  end
4
4
  end
5
5
 
6
- %w(campfire passenger ping symlink).each { |m| require "chinook/capistrano/#{m}" }
6
+ %w(campfire passenger ping slack symlink).each do |m|
7
+ require "chinook/capistrano/#{m}"
8
+ end
@@ -1,3 +1,3 @@
1
1
  module Chinook
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
data/readme.markdown CHANGED
@@ -73,6 +73,27 @@ Pings the site after a [Passenger](phusionpassenger.com) deploy to ensure that i
73
73
  * Settings:
74
74
  - `:ping_url`: the URL you'd like to ping to wake up. *Environment specific.*
75
75
 
76
+ ### Slack notification
77
+
78
+ Notifies [Slack](https://slack.com) when a deploy starts and/or stops. Uses the value of `git config user.name` for identifying the deploying user.
79
+
80
+ * Tasks:
81
+ - `chinook:slack_start`
82
+ - `chinook:slack_fail`
83
+ - `chinook:slack_end`
84
+ * Hooks:
85
+ - `before 'deploy', 'chinook:slack_start'`
86
+ - `after 'deploy:rollback', 'chinook:slack_rollback'`
87
+ - `after 'deploy', 'chinook:slack_end'`
88
+ * Settings:
89
+ - `:slack_channel`: the room/channel where notifications will be posted.
90
+ - `:slack_token`: the Slack webhook token for your team.
91
+ - `:slack_team`: the subdomain of your Slack account (**this-part**.slack.com).
92
+ - `:slack_username`: the username to be used when posting the message.
93
+ - `:project_name`: the name of your project as it will show up in the notifications. *Optional; if not supplied, the value of `:application` will be used.*
94
+ - `:slack_icon_url`: the URL to an icon to be used as the icon of the posting webhook. *Optional; if not supplied, Slack's default icon will be used.*
95
+ - `:slack_shipit`: if true, shows the `:shipit:` emoji in the message.
96
+
76
97
  ### Symlink
77
98
 
78
99
  Symlinks directories from various other directories into your project.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: captainu-chinook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Kreeger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-22 00:00:00.000000000 Z
11
+ date: 2014-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.9.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: slack-notifier
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.4.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.4.1
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -82,6 +96,7 @@ files:
82
96
  - lib/chinook/capistrano/campfire.rb
83
97
  - lib/chinook/capistrano/passenger.rb
84
98
  - lib/chinook/capistrano/ping.rb
99
+ - lib/chinook/capistrano/slack.rb
85
100
  - lib/chinook/capistrano/symlink.rb
86
101
  - lib/chinook/version.rb
87
102
  - license.markdown