Skip to content

Commit fd0768d

Browse files
committed
Notify all channels
1 parent bdc59ca commit fd0768d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

bin/git-sync-check.rb

+11-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ def git(*cmd)
3333

3434
module Slack
3535
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+
]
3641

3742
class << self
3843
def notify(message)
@@ -44,19 +49,21 @@ def notify(message)
4449
}
4550

4651
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
4956
end
5057

5158
private
5259

53-
def post(url, payload:)
60+
def post(url, payload:, channel:)
5461
uri = URI.parse(url)
5562
http = Net::HTTP.new(uri.host, uri.port)
5663
http.use_ssl = (uri.scheme == 'https')
5764
http.start do
5865
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 })
6067
http.request(req)
6168
end
6269
end

0 commit comments

Comments
 (0)