kapost_deploy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8a0ed543f7bb6760e3719e3be2d7281ad9bc84b
|
4
|
+
data.tar.gz: 0e78c6acf9e48f70a88f0650ba4ffaceef74aa29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 084d139d05b57f77a445b0928b5ec62671ede37718df3f72c31c4d082b4ebc252437361d9dd867871835d6b86d57e9ca3f2457db71f1c900d631184ccd2abf46
|
7
|
+
data.tar.gz: 419a829ed7c06727ee931a65135e0597181435bb4736fcb01435cf7c9f05bd98d5ad9eb7fc87a6e94b329f22850a407d262aea234c981798dfb3195d90897069
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "slack-notify"
|
2
|
+
|
3
|
+
module KapostDeploy
|
4
|
+
module Plugins
|
5
|
+
module Slack
|
6
|
+
# Wrapper for slack-notify gem
|
7
|
+
class Notifier
|
8
|
+
def initialize(slack_config)
|
9
|
+
self.slack_config = slack_config
|
10
|
+
end
|
11
|
+
|
12
|
+
def notify_slack(message)
|
13
|
+
return unless configured?
|
14
|
+
slack.notify(message)
|
15
|
+
end
|
16
|
+
|
17
|
+
def identity
|
18
|
+
@identity ||= `whoami`.chomp
|
19
|
+
end
|
20
|
+
|
21
|
+
def configured?
|
22
|
+
!slack_config.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def slack
|
28
|
+
@slack ||= SlackNotify::Client.new(slack_config)
|
29
|
+
end
|
30
|
+
|
31
|
+
attr_accessor :slack_config
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "kapost_deploy/plugins/slack/notifier"
|
2
|
+
|
3
|
+
module KapostDeploy
|
4
|
+
module Plugins
|
5
|
+
# After-promotion plugin to notify via slack after a promotion is complete with an
|
6
|
+
# optional message.
|
7
|
+
class SlackAfterPromote
|
8
|
+
def initialize(config, notifier: Slack::Notifier.new(config.fetch(:slack_config, nil)))
|
9
|
+
self.config = config
|
10
|
+
self.notifier = notifier
|
11
|
+
end
|
12
|
+
|
13
|
+
def before
|
14
|
+
end
|
15
|
+
|
16
|
+
def after
|
17
|
+
return unless notifier.configured?
|
18
|
+
|
19
|
+
addl = slack_config.fetch(:additional_message, "")
|
20
|
+
addl = "\n#{addl}" unless addl.empty?
|
21
|
+
|
22
|
+
message = "#{identity} promoted *#{config.app}* to *#{config.to.join(",")}*#{addl}"
|
23
|
+
notifier.notify(message)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_accessor :notifier
|
29
|
+
|
30
|
+
attr_accessor :config
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "kapost_deploy/plugins/slack/notifier"
|
2
|
+
require "git"
|
3
|
+
|
4
|
+
module KapostDeploy
|
5
|
+
module Plugins
|
6
|
+
# Before-promotion plugin to notify slack with a github comparison warning
|
7
|
+
class SlackGithubDiff
|
8
|
+
def initialize(config, notifier: Slack::Notifier.new(config.fetch(:slack_config, nil)))
|
9
|
+
self.behind_app = config.to[0]
|
10
|
+
self.ahead_app = config.app
|
11
|
+
self.github_config = config.fetch(:github_config, nil)
|
12
|
+
self.notifier = notifier
|
13
|
+
end
|
14
|
+
|
15
|
+
def before
|
16
|
+
return unless configured?
|
17
|
+
|
18
|
+
count = commit_count(behind_sha1, ahead_sha1)
|
19
|
+
link = github_compare_url(behind_sha1, ahead_sha1)
|
20
|
+
|
21
|
+
notifier.notify("#{identity} is promoting #{count} commits to *#{config.to.join(",")}*: #{link}")
|
22
|
+
end
|
23
|
+
|
24
|
+
def after
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def behind_sha1
|
30
|
+
@behind_sha1 ||= heroku_head_sha1(behind_app)
|
31
|
+
end
|
32
|
+
|
33
|
+
def ahead_sha1
|
34
|
+
@ahead_sha1 ||= heroku_head_sha1(ahead_app)
|
35
|
+
end
|
36
|
+
|
37
|
+
attr_accessor :notifier
|
38
|
+
attr_accessor :github_config
|
39
|
+
attr_accessor :behind_app
|
40
|
+
attr_accessor :ahead_app
|
41
|
+
|
42
|
+
def configured?
|
43
|
+
!git_config.nil? && notifier.configured?
|
44
|
+
end
|
45
|
+
|
46
|
+
def heroku_head_sha1(app)
|
47
|
+
Git.ls_remote("https://git.heroku.com/#{app}.git")["head"][:sha]
|
48
|
+
end
|
49
|
+
|
50
|
+
def commit_count(behind_sha, ahead_sha)
|
51
|
+
git.log.between(behind_sha, ahead_sha).size
|
52
|
+
end
|
53
|
+
|
54
|
+
def github_compare_url(behind_sha, ahead_sha)
|
55
|
+
"https://github.com/#{github_config[:repo]}/compare/#{behind_sha}...#{ahead_sha}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def git
|
59
|
+
@git ||= Git.open(__dir__, log: Logger.new(STDOUT))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kapost_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Croft
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '10.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '10.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -273,6 +273,9 @@ files:
|
|
273
273
|
- README.md
|
274
274
|
- lib/kapost_deploy.rb
|
275
275
|
- lib/kapost_deploy/identity.rb
|
276
|
+
- lib/kapost_deploy/plugins/slack/notifier.rb
|
277
|
+
- lib/kapost_deploy/plugins/slack_after_promote.rb
|
278
|
+
- lib/kapost_deploy/plugins/slack_github_diff.rb
|
276
279
|
- lib/kapost_deploy/task.rb
|
277
280
|
- lib/tasks/console.rake
|
278
281
|
- lib/tasks/rspec.rake
|