bake-gem-github 0.3.1 → 0.4.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/context/getting-started.md +4 -0
- data/lib/bake/gem/github/project.rb +21 -6
- data/lib/bake/gem/github/version.rb +1 -1
- data/readme.md +4 -0
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 46cf12965bbeacaeb560e4ea719f9976543dca995fc1fde8a472ecb534327cd2
|
|
4
|
+
data.tar.gz: 0c8f8748fd2ef7c93bd3e6dd4ea185165db0e24209c8b33a176b0a58d00b9b41
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0db75dbe12482f9f9c601d6f2f8e473832186de8a1609e17f94b9c4876f90234e6273a4cf0d4a4a003ad9457591bd1d00f6aacb7de0bc5cddf621e61c76c5307
|
|
7
|
+
data.tar.gz: b0d57a706b49d95cccb9023efb014399c1039bc1a38528643e8aa7046516fe4341c2fdc9ac10d097a4429d23ecf7d19d6b5abdca5b3e048e3791eb80f9cda09d
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/context/getting-started.md
CHANGED
|
@@ -69,10 +69,14 @@ reviewers:
|
|
|
69
69
|
|
|
70
70
|
Replace `your-org/managers` with your organization and team slug, for example `socketry/managers`. Individual user logins are also supported. Reviewers need at least read access to the repository. Setup resolves their GitHub IDs without changing repository access or team membership.
|
|
71
71
|
|
|
72
|
+
Reviewer teams must have **Visible** visibility in GitHub team settings. Plan and apply reject **Secret** teams before changing any settings, because GitHub can silently discard them from the environment reviewer list. Setup does not change team visibility.
|
|
73
|
+
|
|
72
74
|
GitHub accepts one to six users or teams, and **one approval from any listed reviewer or team member is sufficient**. It does not support a minimum environment approval count. The default two PR approvals are independent of this publishing approval.
|
|
73
75
|
|
|
74
76
|
Create the environment and restrict its deployment branch as described above before running plan or apply with reviewers configured. The plan previews the current and desired environment settings. Apply replaces its reviewer list while preserving its wait timer, self-review prevention, administrator bypass setting, and deployment branch restrictions. Custom deployment protection rules are managed separately and are not modified. Reapplying an identical reviewer list leaves the environment unchanged.
|
|
75
77
|
|
|
78
|
+
After updating the environment, apply reads its settings back and fails if the reviewer identities or preserved protections differ from the requested configuration. Reviewer order does not matter. Earlier updates may already have completed; inspect the environment in GitHub and rerun `gem:github:setup:plan` before retrying apply.
|
|
79
|
+
|
|
76
80
|
Omitting `reviewers` leaves environment settings unmanaged, including any existing reviewer requirement. An empty list is rejected. To remove an existing requirement, change the environment settings explicitly in GitHub.
|
|
77
81
|
|
|
78
82
|
The RubyGems Trusted Publisher must explicitly require the `rubygems` environment; leaving that field blank would allow this trusted publisher to authenticate jobs without the environment approval. Keep administrator bypass enabled if administrators should be able to explicitly authorize publication without a reviewer. Environment approvals are available for public repositories on GitHub Free.
|
|
@@ -157,6 +157,7 @@ module Bake
|
|
|
157
157
|
|
|
158
158
|
# Return a read-only comparison of managed settings and current repository settings.
|
|
159
159
|
# @returns [Hash] Desired rules, existing rules, environments, optional environment changes, and expected Trusted Publisher settings. This does not verify RubyGems ownership or publisher configuration.
|
|
160
|
+
# @raises [RuntimeError] If a reviewer team is secret or belongs to another organization.
|
|
160
161
|
def doctor
|
|
161
162
|
{
|
|
162
163
|
desired_rules: Setup.rules(@config),
|
|
@@ -174,8 +175,9 @@ module Bake
|
|
|
174
175
|
|
|
175
176
|
# Apply the named rulesets and configured reviewers for an existing environment. Invoke after reviewing doctor output.
|
|
176
177
|
# Preserves the environment's wait timer, self-review prevention, administrator bypass, and branch restrictions.
|
|
178
|
+
# Reads back updated environment settings to verify GitHub retained them.
|
|
177
179
|
# @returns [Hash] The desired ruleset payloads after successful application.
|
|
178
|
-
# @raises [RuntimeError] If
|
|
180
|
+
# @raises [RuntimeError] If a reviewer team is unsuitable, managed rulesets are ambiguous, or environment verification fails. Earlier updates may already have completed.
|
|
179
181
|
# @raises [Bake::Gem::CommandExecutionError] If an API operation fails; earlier updates may already have completed.
|
|
180
182
|
def apply
|
|
181
183
|
changes = environment_changes
|
|
@@ -193,6 +195,9 @@ module Bake
|
|
|
193
195
|
|
|
194
196
|
if changes && changes.fetch(:current) != changes.fetch(:desired)
|
|
195
197
|
write_api("repos/#{@repository}/#{environment_path}", changes.fetch(:desired), method: "PUT")
|
|
198
|
+
unless environment_settings == changes.fetch(:desired)
|
|
199
|
+
raise "GitHub did not retain the requested settings for environment #{changes.fetch(:name)}. Check its reviewers and protection rules in GitHub, then rerun gem:github:setup:plan."
|
|
200
|
+
end
|
|
196
201
|
end
|
|
197
202
|
|
|
198
203
|
return rules
|
|
@@ -209,19 +214,26 @@ module Bake
|
|
|
209
214
|
return nil unless @config.key?("reviewers")
|
|
210
215
|
Setup.validate_reviewers(@config["reviewers"])
|
|
211
216
|
|
|
217
|
+
current = environment_settings
|
|
218
|
+
reviewers = @config.fetch("reviewers").map{|name| resolve_reviewer(name)}.uniq.sort_by{|reviewer| reviewer.values_at(:type, :id)}
|
|
219
|
+
|
|
220
|
+
return {name: @config.fetch("environment"), current: current, desired: current.merge(reviewers: reviewers)}
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Read the environment settings, comparing reviewer identities independently of their order.
|
|
224
|
+
def environment_settings
|
|
212
225
|
environment = api(environment_path)
|
|
213
226
|
protections = environment.fetch("protection_rules").to_h{|rule| [rule.fetch("type"), rule]}
|
|
214
227
|
reviews = protections.fetch("required_reviewers", {})
|
|
215
|
-
|
|
228
|
+
reviewers = reviews.fetch("reviewers", []).map{|entry| {type: entry.fetch("type"), id: entry.fetch("reviewer").fetch("id")}}
|
|
229
|
+
|
|
230
|
+
return {
|
|
216
231
|
wait_timer: protections.fetch("wait_timer", {}).fetch("wait_timer", 0),
|
|
217
232
|
prevent_self_review: reviews.fetch("prevent_self_review", false),
|
|
218
233
|
can_admins_bypass: environment.fetch("can_admins_bypass"),
|
|
219
234
|
deployment_branch_policy: environment.fetch("deployment_branch_policy"),
|
|
220
|
-
reviewers:
|
|
235
|
+
reviewers: reviewers.uniq.sort_by{|reviewer| reviewer.values_at(:type, :id)},
|
|
221
236
|
}
|
|
222
|
-
reviewers = @config.fetch("reviewers").map{|name| resolve_reviewer(name)}
|
|
223
|
-
|
|
224
|
-
return {name: @config.fetch("environment"), current: current, desired: current.merge(reviewers: reviewers)}
|
|
225
237
|
end
|
|
226
238
|
|
|
227
239
|
def resolve_reviewer(name)
|
|
@@ -235,6 +247,9 @@ module Bake
|
|
|
235
247
|
type = "User"
|
|
236
248
|
end
|
|
237
249
|
response = JSON.parse(readlines("gh", "api", path, chdir: @root).join)
|
|
250
|
+
if type == "Team" && response.fetch("privacy") == "secret"
|
|
251
|
+
raise "Reviewer team #{name} is Secret. Change its visibility to Visible in GitHub team settings before running setup."
|
|
252
|
+
end
|
|
238
253
|
|
|
239
254
|
return {type: type, id: response.fetch("id")}
|
|
240
255
|
end
|
data/readme.md
CHANGED
|
@@ -24,6 +24,10 @@ Please see the [project documentation](https://socketry.github.io/bake-gem-githu
|
|
|
24
24
|
|
|
25
25
|
Please see the [project releases](https://socketry.github.io/bake-gem-github/releases/index) for all releases.
|
|
26
26
|
|
|
27
|
+
### v0.4.0
|
|
28
|
+
|
|
29
|
+
- Reject Secret environment reviewer teams before applying release settings, and verify that GitHub retained the requested reviewers and existing protections after updating the environment.
|
|
30
|
+
|
|
27
31
|
### v0.3.1
|
|
28
32
|
|
|
29
33
|
- Publish validated release PRs from pushes to the default branch, retaining the exact merged commit and environment approval without requiring `pull_request_target`.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.4.0
|
|
4
|
+
|
|
5
|
+
- Reject Secret environment reviewer teams before applying release settings, and verify that GitHub retained the requested reviewers and existing protections after updating the environment.
|
|
6
|
+
|
|
3
7
|
## v0.3.1
|
|
4
8
|
|
|
5
9
|
- Publish validated release PRs from pushes to the default branch, retaining the exact merged commit and environment approval without requiring `pull_request_target`.
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
C�R�EDJ�X6C�����C0�5��5!�G�NXyA2hxv4�
|
|
2
|
+
g|˒�ph%=�h݉�͒
|
|
3
|
+
��=P�C���x��HP@9��#�C*����CT��
|
|
4
|
+
06^��P��cg�l[�8nqGX^�Grdf �斉�C�v��0��?��wM=��>����H�[�b ����(g:&���-�6囀R�w���so#�yp(;
|