ops_deploy 0.1.8.4 → 0.1.8.5.b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5102cf39c639b4632234d7046c4578fe64f6375e
4
- data.tar.gz: 6d3ac1074e8788c01efe04b783f1faa257e1b1f6
3
+ metadata.gz: 66b624d560e2da81965036384e92718b5697b41c
4
+ data.tar.gz: f597d3ead3813d39513e8e540674eaeb39469e56
5
5
  SHA512:
6
- metadata.gz: cf75ff37b32e8e15922bc1422048c4afd785323fb71d8df15370f5130eeed184d2930e8e92566d2d450a0728b5b40fd8016c9b7060f751fc35b57237155f339b
7
- data.tar.gz: 005b51906d84d44dfce7ee01af43a68f1869d475ab3abae2e9ff4f02a5e2252942784af6d6c6e5423e5df0eb5b7a4877dd89b1923106596abeacd20d1a30138f
6
+ metadata.gz: 812164ce60648a3881b1f0804919cf27451d385ecded1f74273a872ee6723db62ee64421848f6e0bcccc12fa746aee03e0afdd58bc2f9ad5e149faad0c48403d
7
+ data.tar.gz: c8f39b8005bc58077471c6d17f4f98806baaaa3fc2aaea8136b80d7feef3fb2eb3133fe633f596f2a96124085bb7f1672fe9ff0fa5af38f80f2ef92b0e2c9953
@@ -4,6 +4,7 @@ require 'colorize'
4
4
  require 'slack-notifier'
5
5
  require 'pusher'
6
6
  require 'pusher-client'
7
+ require 'octokit'
7
8
 
8
9
  class OpsDeploy
9
10
  attr_accessor :waiter
@@ -17,6 +17,23 @@ class OpsDeploy::CLI
17
17
 
18
18
  @main = OpsDeploy.new(config)
19
19
  @stacks = {}
20
+
21
+ github_token = OpsDeploy::CLI.argument('github-token', 'GITHUB_TOKEN')
22
+ auto_inactive = OpsDeploy::CLI.argument('github-deployment-auto-inactive')
23
+ auto_inactive = [nil, "", "1", "true", "TRUE"].include?(auto_inactive)
24
+
25
+ @github = OpsDeploy::CLI::GitHub.new(github_token, {
26
+ owner: OpsDeploy::CLI.argument('github-deployment-owner'),
27
+ repo: OpsDeploy::CLI.argument('github-deployment-repo'),
28
+ deployment_id: OpsDeploy::CLI.argument('github-deployment-deployment-id'),
29
+ options: {
30
+ log_url: OpsDeploy::CLI.argument('github-deployment-log-url'),
31
+ description: OpsDeploy::CLI.argument('github-deployment-description'),
32
+ environment_url: OpsDeploy::CLI.argument('github-deployment-environment-url'),
33
+ auto_inactive: auto_inactive
34
+ }
35
+ })
36
+
20
37
  @notifier = OpsDeploy::CLI::Notifier.new(slack: {
21
38
  webhook_url: OpsDeploy::CLI.argument('slack-webhook-url', 'SLACK_WEBHOOK_URL'),
22
39
  username: OpsDeploy::CLI.argument('slack-username', 'SLACK_USERNAME'),
@@ -64,18 +81,23 @@ class OpsDeploy::CLI
64
81
  if via_proxy
65
82
  Pusher.url = OpsDeploy::CLI.argument('pusher-url', 'PUSHER_URL', true)
66
83
  Pusher.trigger('OpsDeploy', 'wait_for_deployments', stack: stack.stack_id,
67
- slack: @notifier.options[:slack])
84
+ slack: @notifier.options[:slack],
85
+ github: @github.deployment_info)
68
86
  else
69
87
  step_msg('Checking deployments...')
70
88
 
89
+ github = @github.dup
90
+
71
91
  @main.deployments_callback = proc { |deployment|
72
92
  puts
73
93
  if (deployment.status == 'successful')
74
94
  success_msg('Deployment', 'OK'.green.bold,
75
95
  deployment.duration ? "(#{deployment.duration}s)" : '')
96
+ github.create_deployment_status("success")
76
97
  else
77
98
  failure_msg('Deployment', 'Failed'.red.bold,
78
99
  deployment.duration ? "(#{deployment.duration}s)" : '')
100
+ github.create_deployment_status("error")
79
101
  end
80
102
  }
81
103
 
@@ -154,6 +176,8 @@ class OpsDeploy::CLI
154
176
  info = data
155
177
  info = symbolize_keys(JSON.parse(data)) if data.is_a?(String)
156
178
 
179
+ @github.deployment_info = info[:github]
180
+
157
181
  with_slack(info[:slack]) do
158
182
  wait_for_deployments(info[:stack])
159
183
  end
@@ -284,4 +308,5 @@ class OpsDeploy::CLI
284
308
  end
285
309
  end
286
310
 
311
+ require_relative 'cli/github'
287
312
  require_relative 'cli/notifier'
@@ -0,0 +1,30 @@
1
+ class OpsDeploy::CLI::GitHub
2
+ attr_accessor :deployment_info
3
+
4
+ def initialize(token, deployment_info)
5
+ self.token = token
6
+ self.deployment_info = deployment_info
7
+ end
8
+
9
+ def create_deployment_status(state)
10
+ return unless valid?
11
+
12
+ owner, repo = deployment_info[:owner], deployment_info[:repo]
13
+ deployment_id = deployment_info[:deployment_id]
14
+ url = "https://api.github.com/repos/#{owner}/#{repo}/deployments/#{deployment_id}"
15
+
16
+ client = Octokit::Client.new(access_token: token)
17
+ client.create_deployment_status(url, state, deployment_info[:options])
18
+
19
+ self.deployment_info = nil
20
+ end
21
+
22
+ def valid?
23
+ token && deployment_info &&
24
+ deployment_info[:owner] && deployment_info[:repo] && deployment_info[:deployment_id]
25
+ end
26
+
27
+ private
28
+
29
+ attr_accessor :token
30
+ end
@@ -1,3 +1,3 @@
1
1
  class OpsDeploy
2
- VERSION = '0.1.8.4'
2
+ VERSION = '0.1.8.5.b'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ops_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.4
4
+ version: 0.1.8.5.b
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mahdi Bchetnia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-11 00:00:00.000000000 Z
11
+ date: 2016-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: octokit
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '4.3'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '4.3'
97
111
  description: Perform deployment & checks on AWS OpsWorks. You can deploy, wait for
98
112
  deployments to finish, and check on the instances responses for a successful deployment
99
113
  flow. Also implements Slack notifications for each step.
@@ -108,6 +122,7 @@ files:
108
122
  - bin/opsdeploy
109
123
  - lib/ops_deploy.rb
110
124
  - lib/ops_deploy/cli.rb
125
+ - lib/ops_deploy/cli/github.rb
111
126
  - lib/ops_deploy/cli/notifier.rb
112
127
  - lib/ops_deploy/version.rb
113
128
  - lib/ops_deploy/waiter.rb