escobar 0.1.25 → 0.1.26

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: 3053ef50278243327fed5815fe4058fe6c1196c1
4
- data.tar.gz: 400aae27fba0570703eb96b7e3ce7ddf78744af2
3
+ metadata.gz: 27a470255b00c4fcdbab4f72c00b0ad756240ae6
4
+ data.tar.gz: 30f72aea16837ba7e86e96a67895db5fcf632307
5
5
  SHA512:
6
- metadata.gz: f74963b57576b393bd77bbfb882e1f8fde3378d7cc329c434215725caa36e247792c1da54b80c1350d42751748d09ff3554fe10d87ddb97b04036fa57be091da
7
- data.tar.gz: f9ccfd75f00484dfe9ed8320e60338f04bb78be2838bbf951fcc69e57f12cce2f25af209d2daab04cfe7c22d1e1243a33e2eb36fd64b78ba8525ad5ca9b1b22a
6
+ metadata.gz: 0c78de4e0a6286598f8ba10661b4f11816b27d9a8c6245c800b5646abc8b4fa4fce215b9a6dbd29cc98fcecc688031563de6b73f639c168fb7d85abf30dab47b
7
+ data.tar.gz: 7d6d8127c085ad61d01ee9686ee0a6af77f0c7fe1e73cad00867df3e14a49c8d0ca7161991161fe061328d7f56a7cbf7a1c3bcba2fd20b37b6efd997fbbc53bf
@@ -25,6 +25,25 @@ module Escobar
25
25
  response && response.headers && response.headers["Location"]
26
26
  end
27
27
 
28
+ def required_contexts
29
+ path = "/repos/#{name_with_owner}/branches/#{default_branch}"
30
+ repo = JSON.parse(http_method(:get, path).body)
31
+ if repo["protection"] && repo["protection"]["enabled"]
32
+ return repo["protection"]["required_status_checks"]["contexts"]
33
+ else
34
+ []
35
+ end
36
+ rescue StandardError
37
+ []
38
+ end
39
+
40
+ def default_branch
41
+ response = http_method(:get, "/repos/#{name_with_owner}")
42
+ JSON.parse(response.body)["default_branch"]
43
+ rescue StandardError
44
+ "master"
45
+ end
46
+
28
47
  def create_deployment(options)
29
48
  body = {
30
49
  ref: options[:ref] || "master",
@@ -54,10 +73,14 @@ module Escobar
54
73
  response && response.body
55
74
  end
56
75
 
76
+ def accept_headers
77
+ "application/vnd.github.loki-preview+json"
78
+ end
79
+
57
80
  def http_method(verb, path)
58
81
  client.send(verb) do |request|
59
82
  request.url path
60
- request.headers["Accept"] = "application/vnd.github+json"
83
+ request.headers["Accept"] = accept_headers
61
84
  request.headers["Content-Type"] = "application/json"
62
85
  request.headers["Authorization"] = "token #{token}"
63
86
  end
@@ -66,7 +89,7 @@ module Escobar
66
89
  def post(path, body)
67
90
  response = client.post do |request|
68
91
  request.url path
69
- request.headers["Accept"] = "application/vnd.github+json"
92
+ request.headers["Accept"] = accept_headers
70
93
  request.headers["Content-Type"] = "application/json"
71
94
  request.headers["Authorization"] = "token #{token}"
72
95
  request.body = body.to_json
@@ -134,10 +134,10 @@ module Escobar
134
134
  options = {
135
135
  ref: ref,
136
136
  task: task,
137
- environment: environment,
138
- required_contexts: [],
139
137
  auto_merge: !force,
140
- payload: extras.merge(custom_deployment_payload)
138
+ payload: extras.merge(custom_deployment_payload),
139
+ environment: environment,
140
+ required_contexts: github_client.required_contexts
141
141
  }
142
142
  github_client.create_deployment(options)
143
143
  end
@@ -1,3 +1,3 @@
1
1
  module Escobar
2
- VERSION = "0.1.25".freeze
2
+ VERSION = "0.1.26".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escobar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.25
4
+ version: 0.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Donohoe