capistrano-ikachan 0.0.4 → 0.1.0
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 +4 -4
- data/lib/capistrano/ikachan/version.rb +1 -1
- data/lib/capistrano/tasks/ikachan.rake +66 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db9f4529272f7182ceda62babd36a3be5b48e7a8
|
4
|
+
data.tar.gz: 59c9920b5932cf27929fb235e2a5170cd57edeea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05301318446a69aec69e83697a90f44e49c2b2d98e00304793775ebd7aa5e1dc14565f335f6d0fc9be9eb224d6f3bb558e4b80734eb7c4a295cf0d765e3e45ef
|
7
|
+
data.tar.gz: 94041aa5f0af06bffd96f3b05953430c9b64e5d1a65979e6d89fb10a7d8164b609bac983ea1b4f4d2e339ad7d8a584b20c21495290ae461d1c61b01d0098f344
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Capistrano::Ikachan
|
|
4
4
|
[][gem]
|
5
5
|
[gem]: https://rubygems.org/gems/capistrano-ikachan
|
6
6
|
|
7
|
-
Irc notification tasks
|
7
|
+
Irc notification tasks with Ikachan for Capistrano v3.
|
8
8
|
|
9
9
|
Installation
|
10
10
|
------------
|
@@ -42,9 +42,9 @@ config.rb:
|
|
42
42
|
set ikachan_channel, 'ikachan'
|
43
43
|
set ikachan_server, 'http://ikachan.example.com'
|
44
44
|
|
45
|
-
after 'deploy:
|
46
|
-
after 'deploy:finishing', 'ikachan:
|
47
|
-
after 'deploy:finishing_rollback', 'ikachan:
|
45
|
+
after 'deploy:started', 'ikachan:notify_start'
|
46
|
+
after 'deploy:finishing', 'ikachan:notify_deployment'
|
47
|
+
after 'deploy:finishing_rollback', 'ikachan:notify_rollback'
|
48
48
|
```
|
49
49
|
|
50
50
|
Contributing
|
@@ -1,65 +1,109 @@
|
|
1
1
|
require 'string-irc'
|
2
|
+
require 'digest/md5'
|
2
3
|
|
3
4
|
namespace :ikachan do
|
4
5
|
start = Time.now
|
6
|
+
elapsed_time = -> { sprintf('%.2f', Time.now - start) }
|
5
7
|
|
6
8
|
set :ikachan_channel, 'ikachan'
|
7
9
|
set :ikachan_server, 'http://ikachan.example.com'
|
8
|
-
set :ikachan_message_type,
|
10
|
+
set :ikachan_message_type, :notice
|
9
11
|
|
10
|
-
set :
|
12
|
+
set :ikachan_username, -> {
|
11
13
|
username = `git config --get user.name`.strip
|
12
14
|
username = `whoami`.strip unless username
|
13
15
|
username
|
14
16
|
}
|
15
17
|
|
16
|
-
set :
|
17
|
-
set :
|
18
|
-
set :
|
18
|
+
set :ikachan_start_icon, -> { StringIrc.new('✔').yellow }
|
19
|
+
set :ikachan_failure_icon, -> { StringIrc.new('✘').red }
|
20
|
+
set :ikachan_success_icon, -> { StringIrc.new('✔').light_green }
|
19
21
|
|
20
|
-
set :
|
22
|
+
set :ikachan_stage, -> {
|
21
23
|
stage = "#{fetch(:stage)}"
|
22
24
|
color = case stage
|
23
25
|
when 'production' then :rainbow
|
24
|
-
when 'staging' then :
|
25
|
-
when 'sandbox' then :
|
26
|
+
when 'staging' then :aqua
|
27
|
+
when 'sandbox' then :pink
|
26
28
|
when 'development' then :purple
|
27
|
-
else :
|
29
|
+
else :light_blue
|
28
30
|
end
|
29
31
|
StringIrc.new(stage).send(color)
|
30
32
|
}
|
31
33
|
|
34
|
+
set :ikachan_appname, -> {
|
35
|
+
app = fetch(:application)
|
36
|
+
|
37
|
+
magic_number = Digest::MD5.hexdigest(app).
|
38
|
+
gsub(/[^0-9]/, '').split('').last.to_i
|
39
|
+
|
40
|
+
colors = StringIrc::COLOR_TABLE.select { |k,v|
|
41
|
+
2 < k && k < 13 && k != 4 && k != 13
|
42
|
+
}.map { |k,v| v.last }
|
43
|
+
color = colors[magic_number].to_sym
|
44
|
+
|
45
|
+
StringIrc.new(app).send(color)
|
46
|
+
}
|
47
|
+
|
32
48
|
set :ikachan_start_message, -> {
|
33
|
-
|
49
|
+
<<-MSG.gsub(/\s+/, ' ')
|
50
|
+
#{fetch(:ikachan_appname)}: #{fetch(:ikachan_start_icon)} started deploying
|
51
|
+
to #{fetch(:ikachan_stage)} by #{fetch(:ikachan_username)}
|
52
|
+
(branch #{fetch(:branch)})
|
53
|
+
MSG
|
34
54
|
}
|
35
55
|
|
36
56
|
set :ikachan_failure_message, -> {
|
37
|
-
|
38
|
-
|
57
|
+
<<-MSG.gsub(/\s+/, ' ')
|
58
|
+
#{fetch(:ikachan_appname)}: #{fetch(:ikachan_failure_icon)} failed deploying
|
59
|
+
to #{fetch(:ikachan_stage)} by #{fetch(:ikachan_username)}
|
60
|
+
(branch #{fetch(:branch)} at #{fetch(:current_revision)} / #{elapsed_time.call} sec)
|
61
|
+
MSG
|
39
62
|
}
|
40
63
|
|
41
64
|
set :ikachan_success_message, -> {
|
42
|
-
|
43
|
-
|
65
|
+
task = fetch(:deploying) ? 'deployment' : 'rollback'
|
66
|
+
<<-MSG.gsub(/\s+/, ' ')
|
67
|
+
#{fetch(:ikachan_appname)}: #{fetch(:ikachan_success_icon)} successful #{task}
|
68
|
+
to #{fetch(:ikachan_stage)} by #{fetch(:ikachan_username)}
|
69
|
+
(branch #{fetch(:branch)} at #{fetch(:current_revision)} / #{elapsed_time.call} sec)
|
70
|
+
MSG
|
44
71
|
}
|
45
72
|
|
46
|
-
def
|
73
|
+
def notify_with_ikachan(message)
|
47
74
|
channel = fetch(:ikachan_channel)
|
48
75
|
host = fetch(:ikachan_server)
|
49
76
|
type = fetch(:ikachan_message_type)
|
50
|
-
|
51
|
-
|
77
|
+
|
78
|
+
run_locally do
|
79
|
+
execute :curl, '-s',
|
80
|
+
"-F channel=\##{channel}",
|
81
|
+
"#{host}/join"
|
82
|
+
execute :curl, '-s',
|
83
|
+
"-F channel=\##{channel}",
|
84
|
+
"-F message=\"#{args[:message]}\"",
|
85
|
+
"#{host}/#{type}"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
desc 'Notify message to IRC with Ikachan'
|
90
|
+
task :notify, :message do |t, args|
|
91
|
+
notify_with_ikachan args[:message]
|
52
92
|
end
|
53
93
|
|
94
|
+
desc 'Notify start to IRC with Ikachan'
|
54
95
|
task :notify_start do
|
55
|
-
|
96
|
+
notify_with_ikachan fetch(:ikachan_start_message)
|
56
97
|
end
|
57
98
|
|
58
|
-
|
59
|
-
|
99
|
+
desc 'Notify rollback to IRC with Ikachan'
|
100
|
+
task :notify_rollback do
|
101
|
+
message = fetch(:deploying) ? :ikachan_failure_message : :ikachan_success_message
|
102
|
+
notify_with_ikachan fetch(message)
|
60
103
|
end
|
61
104
|
|
62
|
-
|
63
|
-
|
105
|
+
desc 'Notify deployment to IRC with Ikachan'
|
106
|
+
task :notify_deployment do
|
107
|
+
notify_with_ikachan fetch(:ikachan_success_message)
|
64
108
|
end
|
65
109
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-ikachan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- linyows
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: string-irc
|