-
Notifications
You must be signed in to change notification settings - Fork 10
76 lines (65 loc) · 3.14 KB
/
Copy pathissue-go-no.yml
File metadata and controls
76 lines (65 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: "Issue Go: No"
# Deterministic Workflow: No-Go decision
# Trigger: a maintainer applies the "go:no" label to reject an issue.
# Effect: add the close:wont-fix label and close the issue as "not planned".
#
# ─── SECURITY CONSTRAINTS ───────────────────────────────────────────────
# Only repository maintainers/admins may drive a go:* decision. A non-maintainer
# applying go:no fails the permission gate and no state change is made.
# This workflow does NOT post comments — the maintainer supplies the rejection
# rationale manually, per the go/no-go process.
# ────────────────────────────────────────────────────────────────────────
on:
issues:
types: [labeled]
permissions:
issues: write
contents: read
jobs:
close-nogo:
if: github.event.label.name == 'go:no'
runs-on: ubuntu-latest
steps:
- name: Verify maintainer-triggered event
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const sender = context.payload.sender.login;
const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: sender
});
// The legacy `permission` field collapses the maintain role to
// "write" (and triage to "read"), so it cannot distinguish a
// maintainer from a writer. Use the cumulative permission booleans
// instead — admin/maintain are set for admins and maintainers and
// are robust to custom org roles.
const perms = (permission.user && permission.user.permissions) || {};
const isMaintainer = perms.admin === true || perms.maintain === true;
if (!isMaintainer) {
core.setFailed(
`Only repository maintainers may apply go:* labels. ${sender} has ${permission.role_name || permission.permission} access.`
);
return;
}
core.info(`Verified ${sender} as a ${permission.role_name || permission.permission} collaborator`);
- name: Add close:wont-fix and close as not planned
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const issue_number = context.payload.issue.number;
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number,
labels: ['close:wont-fix']
});
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number,
state: 'closed',
state_reason: 'not_planned'
});
core.info(`Closed issue #${issue_number} as not_planned with the close:wont-fix label`);