capistrano3-notification 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/capistrano3-notification.gemspec +1 -0
- data/lib/capistrano3/notification/tasks/notification.rake +27 -2
- data/lib/capistrano3/notification/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfc1a1b79468f75feab46ebf083d00d8411075b8
|
4
|
+
data.tar.gz: 74986a47b8b44aece6bcf10ae7d6170b2081f7a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df0313a786ae120a27705d7822c95a1955deb9165370c0cbe8e455075b954dc1ce9eb41929ee06f8591cae1e8b447a0830637a5888be50917761a1ee66a01a63
|
7
|
+
data.tar.gz: dc32646913a04454039840f4e2e26edc9716c10891650874e7c06170e03ceacf0db8538ddfc7eae94621a14259d4a6c8c7bb11126dbf56b60109ca345f7a0e50
|
data/README.md
CHANGED
@@ -30,6 +30,17 @@ set :irc_user, 'myproject' # default: 'capistrano'
|
|
30
30
|
set :notification, -> { "#{fetch(:application)} was deployed to #{fetch(:stage)}" } # this message is default
|
31
31
|
```
|
32
32
|
|
33
|
+
### Slack notification
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
set :slack_webhook_url, 'https://hooks.slack.com/services/EX/AM/PLE'
|
37
|
+
set :slack_user, 'myproject' # default: 'capistrano'
|
38
|
+
set :slack_channel, '#notice'
|
39
|
+
set :slack_icon, ':ghost:' # use emoji
|
40
|
+
set :slack_icon, 'http://example.com/icon.png' # use image
|
41
|
+
set :notification, -> { "#{fetch(:application)} was deployed to #{fetch(:stage)}" } # this message is default
|
42
|
+
```
|
43
|
+
|
33
44
|
### Other notification
|
34
45
|
|
35
46
|
**contribute me!**
|
@@ -2,28 +2,53 @@ namespace :load do
|
|
2
2
|
task :defaults do
|
3
3
|
set :irc_port, 6667
|
4
4
|
set :irc_user, 'capistrano'
|
5
|
+
set :slack_user, 'capistrano'
|
5
6
|
set :notification, -> { "#{fetch(:application)} was deployed to #{fetch(:stage)}" }
|
6
7
|
end
|
7
8
|
end
|
8
9
|
|
9
10
|
namespace :notification do
|
10
11
|
task :notify do
|
11
|
-
%w(irc).each do |adapter|
|
12
|
+
%w(irc slack).each do |adapter|
|
12
13
|
invoke "notification:#{adapter}"
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
17
|
task :irc do
|
17
|
-
require 'shout-bot'
|
18
18
|
user = fetch(:irc_user)
|
19
19
|
host = fetch(:irc_host)
|
20
20
|
port = fetch(:irc_port)
|
21
21
|
channel = fetch(:irc_channel)
|
22
22
|
message = fetch(:notification)
|
23
23
|
return unless user && host && port && channel && message
|
24
|
+
require 'shout-bot'
|
24
25
|
url = "irc://#{user}@#{host}:#{port}/#{channel}"
|
25
26
|
ShoutBot.shout(url) { |irc| irc.say message }
|
26
27
|
end
|
27
28
|
|
29
|
+
task :slack do
|
30
|
+
webhook_url = fetch(:slack_webhook_url)
|
31
|
+
name = fetch(:slack_user) || nil
|
32
|
+
channel = fetch(:slack_channel) || nil
|
33
|
+
icon = fetch(:slack_icon) || nil
|
34
|
+
message = fetch(:notification)
|
35
|
+
return unless webhook_url && message
|
36
|
+
require 'slack-notifier'
|
37
|
+
notifier_options = { username: name, channel: channel }.reject { |_x, y| y.nil? }
|
38
|
+
icon_type = case icon
|
39
|
+
when /^:.+:/
|
40
|
+
:icon_emoji
|
41
|
+
when /^http/
|
42
|
+
:icon_url
|
43
|
+
else
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
ping_options = {}.tap do |h|
|
47
|
+
h[icon_type] = icon if icon_type
|
48
|
+
end
|
49
|
+
notifier = Slack::Notifier.new webhook_url, notifier_options
|
50
|
+
notifier.ping message, ping_options
|
51
|
+
end
|
52
|
+
|
28
53
|
after 'deploy:finished', 'notification:notify'
|
29
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano3-notification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masarakki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-26 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: '0'
|
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'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|