codedeploy_slack_notify 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/codedeploy_slack_notify.gemspec +34 -0
- data/exe/codedeploy_slack_notify +76 -0
- data/lib/codedeploy_slack_notify/version.rb +3 -0
- data/lib/codedeploy_slack_notify.rb +5 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6f21bc21f0dec627c458a39fccbc319081045b84
|
4
|
+
data.tar.gz: e99e87366f35928221e027cb192457cc36f8f2f5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 762da81246874d283a32d996561bfd74d8be838a1497faefea9b5640759676ce188da65f92ca954777ce2873781c1d5959ebb2d1f8e1c4f840ae068891dd4626
|
7
|
+
data.tar.gz: 6c27e37f7b06cb12f6554f18171d4966a2e4ce33d65bf22b82b776388b2df158db518d14168e2f9272e33f7b8aaea1bd62f1af62b29eb119bc76ec144d9f4a32
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 hoshinotsuyoshi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# CodedeploySlackNotify
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
TODO: Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'codedeploy_slack_notify'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install codedeploy_slack_notify
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```sh
|
22
|
+
$ SLACK_WEBHOOK_URL="https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx" \
|
23
|
+
SLACK_CHANNEL="#xxxxxxxxxxx" \
|
24
|
+
SLACK_USERNAME=xxxxxxxxxxxxxxxx \
|
25
|
+
DEPLOYMENT_ID=d-xxxxxxx \
|
26
|
+
codedeploy_slack_notify
|
27
|
+
```
|
28
|
+
|
29
|
+
## License
|
30
|
+
|
31
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
32
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "codedeploy_slack_notify"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'codedeploy_slack_notify/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "codedeploy_slack_notify"
|
8
|
+
spec.version = CodedeploySlackNotify::VERSION
|
9
|
+
spec.authors = ["hoshinotsuyoshi"]
|
10
|
+
spec.email = ["guitarpopnot330@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Notify aws codedeploy status.}
|
13
|
+
spec.description = %q{}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_runtime_dependency "aws-sdk-core", "~> 2.3.5"
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'aws-sdk-core'
|
4
|
+
require 'json'
|
5
|
+
require 'net/http'
|
6
|
+
|
7
|
+
DEPLOYMENT_ID = ENV['DEPLOYMENT_ID']
|
8
|
+
unless DEPLOYMENT_ID
|
9
|
+
puts '"$DEPLOYMENT_ID" required.'
|
10
|
+
exit 1
|
11
|
+
end
|
12
|
+
|
13
|
+
SLACK_WEBHOOK_URL = ENV['SLACK_WEBHOOK_URL']
|
14
|
+
unless SLACK_WEBHOOK_URL
|
15
|
+
puts '"$SLACK_WEBHOOK_URL" required.'
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
|
19
|
+
SLACK_CHANNEL = ENV.fetch('SLACK_CHANNEL', '#random')
|
20
|
+
SLACK_USERNAME = ENV.fetch('SLACK_USERNAME', 'bot')
|
21
|
+
SLACK_ICON_EMOJI = ENV.fetch('SLACK_ICON_EMOJI', ':ghost:')
|
22
|
+
SLACK_SSL_PORT = 443
|
23
|
+
GITHUB_URL_PREFIX = 'https://github.com'
|
24
|
+
|
25
|
+
client = Aws::CodeDeploy::Client.new
|
26
|
+
|
27
|
+
deployment_info = client.get_deployment(deployment_id: DEPLOYMENT_ID).deployment_info
|
28
|
+
|
29
|
+
overview = deployment_info.deployment_overview
|
30
|
+
|
31
|
+
if overview.pending.nonzero? || \
|
32
|
+
overview.in_progress.nonzero? || \
|
33
|
+
overview.failed.nonzero? || \
|
34
|
+
overview.succeeded.zero?
|
35
|
+
|
36
|
+
# Deploy has not finished yet.
|
37
|
+
exit 0
|
38
|
+
end
|
39
|
+
|
40
|
+
git_hub_location = deployment_info.
|
41
|
+
revision.
|
42
|
+
git_hub_location
|
43
|
+
|
44
|
+
github_commit_url = [
|
45
|
+
GITHUB_URL_PREFIX,
|
46
|
+
git_hub_location.repository,
|
47
|
+
'commit',
|
48
|
+
git_hub_location.commit_id
|
49
|
+
].join('/')
|
50
|
+
|
51
|
+
message = 'Deployed: ' + github_commit_url
|
52
|
+
|
53
|
+
url = URI(SLACK_WEBHOOK_URL)
|
54
|
+
request = Net::HTTP::Post.new(url.path)
|
55
|
+
json = {
|
56
|
+
channel: SLACK_CHANNEL,
|
57
|
+
username: SLACK_USERNAME,
|
58
|
+
icon_emoji: SLACK_ICON_EMOJI,
|
59
|
+
text: message
|
60
|
+
}.to_json
|
61
|
+
|
62
|
+
request.set_form_data(
|
63
|
+
{'payload' => json},
|
64
|
+
';',
|
65
|
+
)
|
66
|
+
|
67
|
+
https = Net::HTTP.new(url.host, SLACK_SSL_PORT)
|
68
|
+
https.use_ssl = true
|
69
|
+
response = https.start{|http| http.request(request)}
|
70
|
+
|
71
|
+
case response
|
72
|
+
when Net::HTTPOK
|
73
|
+
exit 0
|
74
|
+
else
|
75
|
+
exit 1
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: codedeploy_slack_notify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- hoshinotsuyoshi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.3.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.3.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: ''
|
56
|
+
email:
|
57
|
+
- guitarpopnot330@gmail.com
|
58
|
+
executables:
|
59
|
+
- codedeploy_slack_notify
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- codedeploy_slack_notify.gemspec
|
71
|
+
- exe/codedeploy_slack_notify
|
72
|
+
- lib/codedeploy_slack_notify.rb
|
73
|
+
- lib/codedeploy_slack_notify/version.rb
|
74
|
+
homepage: ''
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata:
|
78
|
+
allowed_push_host: https://rubygems.org
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.5.1
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Notify aws codedeploy status.
|
99
|
+
test_files: []
|