@jakobm/peacekeeper 0.13.0 → 0.14.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.
package/README.md
CHANGED
|
@@ -277,7 +277,8 @@ with **Require branches to be up to date before merging** enabled. Classic branc
|
|
|
277
277
|
protection must enforce checks for administrators too. Alternatively, active
|
|
278
278
|
rulesets must require strict checks and have no bypass actors. Rules inherited
|
|
279
279
|
from the organization are included. Merge queues are not currently an alternative
|
|
280
|
-
to this strict policy.
|
|
280
|
+
to this strict policy. Repositories must also enable **Automatically delete head
|
|
281
|
+
branches** (`delete_branch_on_merge=true`).
|
|
281
282
|
|
|
282
283
|
The PR test job runs `peacekeeper verify-release-protection` before its tests.
|
|
283
284
|
The command checks `GITHUB_BASE_REF`, or `git.defaultBranch` outside PR CI.
|
|
@@ -291,8 +292,9 @@ jobs in its latest PR workflow run. Manual tags without that PR are rejected.
|
|
|
291
292
|
API failures, missing permissions, and unverifiable rules stop the commands.
|
|
292
293
|
The workflow expects a `RELEASE_POLICY_TOKEN` Actions secret, exposed to the
|
|
293
294
|
commands as `GH_TOKEN`. Use a fine-grained PAT or GitHub App token with access to
|
|
294
|
-
this repository and Administration read, Contents read, Pull requests read and
|
|
295
|
-
Actions read permissions.
|
|
295
|
+
this repository and Administration read, Contents read/write, Pull requests read and
|
|
296
|
+
Actions read permissions. Contents write is required even to read merge-related
|
|
297
|
+
settings such as `delete_branch_on_merge`. GitHub only exposes ruleset bypass actors to callers
|
|
296
298
|
with write access to the ruleset; ruleset users must additionally grant that
|
|
297
299
|
access (Administration write for repository rulesets, or the appropriate access
|
|
298
300
|
for inherited organization rulesets). Missing bypass information also fails.
|
|
@@ -303,8 +305,8 @@ by executing fork code with `pull_request_target`.
|
|
|
303
305
|
|
|
304
306
|
To set this up for this repository:
|
|
305
307
|
|
|
306
|
-
1. Open the [token creation form with the required
|
|
307
|
-
For repository rulesets, use the [form with Administration write instead](https://github.com/settings/personal-access-tokens/new?name=peacekeeper-release-policy&target_name=jakobmattsson&expires_in=90&administration=write&contents=
|
|
308
|
+
1. Open the [token creation form with the required permissions prefilled](https://github.com/settings/personal-access-tokens/new?name=peacekeeper-release-policy&target_name=jakobmattsson&expires_in=90&administration=read&contents=write&pull_requests=read&actions=read).
|
|
309
|
+
For repository rulesets, use the [form with Administration write instead](https://github.com/settings/personal-access-tokens/new?name=peacekeeper-release-policy&target_name=jakobmattsson&expires_in=90&administration=write&contents=write&pull_requests=read&actions=read)
|
|
308
310
|
so GitHub exposes bypass actors. For another repository, change the resource
|
|
309
311
|
owner. Select **Only select repositories**, choose `peacekeeper`, review
|
|
310
312
|
the permissions and expiration, and generate the token. If the owner requires
|
package/package.json
CHANGED
|
@@ -184,6 +184,9 @@ Online release policy and GitHub token setup
|
|
|
184
184
|
local declarations above. Use verify-release-protection to check the branch
|
|
185
185
|
policy and verify-release before publishing to check the release itself.
|
|
186
186
|
|
|
187
|
+
Enable "Automatically delete head branches" (delete_branch_on_merge=true) in
|
|
188
|
+
the repository settings. The online release policy commands require it.
|
|
189
|
+
|
|
187
190
|
Configure the default branch from git.defaultBranch with every exact job name
|
|
188
191
|
in git.releaseRequiredChecks mandatory and "Require branches to be up to date
|
|
189
192
|
before merging" enabled. Choose either:
|
|
@@ -197,7 +200,7 @@ Online release policy and GitHub token setup
|
|
|
197
200
|
Create a fine-grained GitHub PAT or GitHub App installation token with access
|
|
198
201
|
to this repository and these repository permissions:
|
|
199
202
|
Administration: read
|
|
200
|
-
Contents: read
|
|
203
|
+
Contents: read/write
|
|
201
204
|
Pull requests: read
|
|
202
205
|
Actions: read
|
|
203
206
|
For repository rulesets, Administration: write is additionally needed because
|
|
@@ -11,6 +11,9 @@ function requiredChecks(cwd) {
|
|
|
11
11
|
// other API failures, including permission failures, must propagate.
|
|
12
12
|
function verifyProtection({ api, slug, branch, checks }) {
|
|
13
13
|
const base = `repos/${slug}`;
|
|
14
|
+
if (api(base)?.delete_branch_on_merge !== true) {
|
|
15
|
+
throw new Error(`Repository ${slug} must enable delete_branch_on_merge. Run gh api --method PATCH ${base} -F delete_branch_on_merge=true, then rerun.`);
|
|
16
|
+
}
|
|
14
17
|
let protection;
|
|
15
18
|
try {
|
|
16
19
|
protection = api(`${base}/branches/${encodeURIComponent(branch)}/protection`);
|
|
@@ -56,7 +59,7 @@ function githubApi(exec, cwd, host) {
|
|
|
56
59
|
return endpoint => {
|
|
57
60
|
const response = exec('gh', ['api', '--hostname', host, '--method', 'GET', endpoint], { cwd });
|
|
58
61
|
if (response.status !== 0) {
|
|
59
|
-
const error = new Error(`Cannot verify GitHub release policy (${endpoint}): ${response.stderr?.trim() || 'API request failed'}. Grant the token Administration read, Contents read, Pull requests read and Actions read permissions, then rerun.`);
|
|
62
|
+
const error = new Error(`Cannot verify GitHub release policy (${endpoint}): ${response.stderr?.trim() || 'API request failed'}. Grant the token Administration read, Contents read/write, Pull requests read and Actions read permissions, then rerun.`);
|
|
60
63
|
error.status = Number(/HTTP (\d{3})/u.exec(response.stderr || '')?.[1]);
|
|
61
64
|
throw error;
|
|
62
65
|
}
|