-
Notifications
You must be signed in to change notification settings - Fork 9
/
review.rake
48 lines (36 loc) · 1.04 KB
/
review.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true
require 'json'
CONFIG = JSON.parse(ENV['CONFIG'])
SLACK_TOKEN = ENV['SLACK_TOKEN']
SLACK_BOT_NAME = 'reviewbot'
SLACK_BOT_ICON = ':robot_face:'
require_relative 'lib/review_bot'
desc 'Send reminders to team members to review PRs'
task :remind, [:mode] do |_t, args|
dry_run = args[:mode] == 'dry'
puts "-- DRY RUN --\n\n" if dry_run
CONFIG.each do |app, app_config|
owner, repo = app.split('/')
room = app_config['room']
puts "#{owner}/#{repo}"
ReviewBot::HourOfDay.work_days = app_config['work_days']
message = ReviewBot::Reminder.new(owner, repo, app_config).message
puts
next if message.nil?
if dry_run
puts "Would deliver message to #{room}"
puts message
puts
else
puts "Delivering a message to #{room}"
RestClient.post(
'https://slack.com/api/chat.postMessage',
token: SLACK_TOKEN,
channel: room,
text: message,
icon_emoji: SLACK_BOT_ICON,
username: SLACK_BOT_NAME
)
end
end
end