pr-notifier 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/pr-notifier +4 -0
- data/lib/pr-notifier.rb +8 -3
- data/lib/pr-notifier/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d06a9da2304c7b76ebbfa6e11c2b92b9a7305aa
|
4
|
+
data.tar.gz: 91d7233d66581839c23fafd37ffaa8bd97110dae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2effbc19a67d8a331cc07685a911bc74dc11bfbbc34c388b25eb7c526861e1823337075da988305fae1608895d84a745b3a44b5166a78297260be5ff21a442c6
|
7
|
+
data.tar.gz: 4a8c2ad6f60638cfed097b3d8384569b3e2e8513191401ca8fd65d8d6aabbe544b812b9d17022206d92018ece404822517561598a99b1c66689c890fa994473e
|
data/bin/pr-notifier
CHANGED
@@ -4,6 +4,9 @@ require "pr-notifier"
|
|
4
4
|
require "optparse"
|
5
5
|
|
6
6
|
OptionParser.new do |opts|
|
7
|
+
opts.on('-d', '--dry-run', 'DRY RUN') do |v|
|
8
|
+
@dry_run = v
|
9
|
+
end
|
7
10
|
opts.on('-g', '--gh-token VALUE', 'GitHub access token ENV:GH_TOKEN') do |v|
|
8
11
|
@gh_token = v
|
9
12
|
end
|
@@ -31,4 +34,5 @@ PrNotifier.run(
|
|
31
34
|
channel: @channel,
|
32
35
|
username: @username,
|
33
36
|
template: @template,
|
37
|
+
dry_run: @dry_run,
|
34
38
|
)
|
data/lib/pr-notifier.rb
CHANGED
@@ -5,7 +5,7 @@ require "slack-notifier"
|
|
5
5
|
|
6
6
|
module PrNotifier
|
7
7
|
module_function
|
8
|
-
def run(gh_token: nil, repos: nil, webhook_url: nil, channel: nil, username: nil, template: nil)
|
8
|
+
def run(gh_token: nil, repos: nil, webhook_url: nil, channel: nil, username: nil, template: nil, dry_run: false)
|
9
9
|
gh_token ||= ENV['GH_TOKEN']
|
10
10
|
repos = (repos || ENV['GH_REPOS'])&.split(',')
|
11
11
|
webhook_url ||= ENV["SLACK_WEBHOOK_URL"]
|
@@ -20,8 +20,13 @@ module PrNotifier
|
|
20
20
|
gh_client = Github.new(access_token: gh_token)
|
21
21
|
prs = repos.each_with_object([]) { |repo, prs| prs.concat(gh_client.fetch_prs_by(repo)) }
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
send_message = message(pull_requests: prs)
|
24
|
+
if dry_run
|
25
|
+
puts send_message
|
26
|
+
else
|
27
|
+
notifier = Slack::Notifier.new(webhook_url, channel: channel, username: username)
|
28
|
+
notifier.ping(message(pull_requests: prs))
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
def message(pull_requests:)
|
data/lib/pr-notifier/version.rb
CHANGED