File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ def git(*cmd)
33
33
34
34
module Slack
35
35
WEBHOOK_URL = File . read ( File . expand_path ( '~git/config/slack-webhook-alerts' ) ) . chomp
36
+ NOTIFY_CHANNELS = [
37
+ "C5FCXFXDZ" , # alerts
38
+ "CR2QGFCAE" , # alerts-emoji
39
+ "CUEBRBFLH" , # alerts3
40
+ ]
36
41
37
42
class << self
38
43
def notify ( message )
@@ -44,19 +49,21 @@ def notify(message)
44
49
}
45
50
46
51
payload = { username : 'ruby/ruby-commit-hook' , attachments : [ attachment ] }
47
- resp = post ( WEBHOOK_URL , payload : payload )
48
- puts "#{ resp . code } (#{ resp . body } ) -- #{ payload . to_json } "
52
+ NOTIFY_CHANNELS . each do |channel |
53
+ resp = post ( WEBHOOK_URL , payload : payload , channel : channel )
54
+ puts "#{ resp . code } (#{ resp . body } ) -- #{ payload . to_json } (channel: #{ channel } )"
55
+ end
49
56
end
50
57
51
58
private
52
59
53
- def post ( url , payload :)
60
+ def post ( url , payload :, channel : )
54
61
uri = URI . parse ( url )
55
62
http = Net ::HTTP . new ( uri . host , uri . port )
56
63
http . use_ssl = ( uri . scheme == 'https' )
57
64
http . start do
58
65
req = Net ::HTTP ::Post . new ( uri . path )
59
- req . set_form_data ( payload : payload . to_json )
66
+ req . set_form_data ( { payload : payload . to_json , channel : channel } )
60
67
http . request ( req )
61
68
end
62
69
end
You can’t perform that action at this time.
0 commit comments