forked from gastownhall/gastown
-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (52 loc) · 2.07 KB
/
Copy pathremove-needs-info.yml
File metadata and controls
61 lines (52 loc) · 2.07 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
name: Remove needs-info on author response
on:
issue_comment:
types: [created]
pull_request_target:
types: [synchronize]
permissions: {}
jobs:
# pull_request_target is safe here because this job never checks out or runs
# pull request code; it only removes labels from the issue/PR metadata.
remove-label:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Remove needs-info / needs-repro on author response
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
const labels = ['status/needs-info', 'status/needs-repro'];
// Determine issue/PR number and author
let number, author;
if (context.eventName === 'issue_comment') {
number = context.payload.issue.number;
author = context.payload.issue.user.login;
// Only act when the original author comments
if (context.payload.comment.user.login !== author) return;
} else {
// pull_request_target / synchronize
number = context.payload.pull_request.number;
author = context.payload.pull_request.user.login;
// Only act when the PR author pushes
if (context.payload.sender.login !== author) return;
}
// Get current labels on the issue/PR
const current = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: number,
});
const currentNames = current.data.map(l => l.name);
for (const label of labels) {
if (!currentNames.includes(label)) continue;
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: number,
name: label,
});
console.log(`Removed '${label}' from #${number}`);
}