-
Notifications
You must be signed in to change notification settings - Fork 650
52 lines (44 loc) · 1.67 KB
/
change-on-reopen.yml
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
name: "Remove status labels and assignee when the issue is reopened"
on:
issues:
types: [reopened]
jobs:
remove_labels_assignees:
if: ${{ github.repository == 'AdguardTeam/AdguardFilters' }}
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const issueNumber = context.issue.number;
const issueLabelsRaw = await github.rest.issues.listLabelsOnIssue({
owner,
repo,
issue_number: issueNumber,
});
const issueLabels = issueLabelsRaw.data.map((el) => el.name);
const labelsToRemove = [ 'A: Resolved', 'A: Cannot reproduce', 'A: In progress', 'A: Waiting for data' ];
for (let label of labelsToRemove) {
if (issueLabels.includes(label)) {
console.log(`Removing ${label} from #${issueNumber}`);
await github.rest.issues.removeLabel({
owner,
repo,
issue_number: issueNumber,
name: label,
});
}
}
const assignees = context.payload.issue.assignees.map(a => a.login);
if (assignees.length !== 0) {
console.log(`Removing assignees ${assignees} from #${issueNumber}`);
await github.rest.issues.removeAssignees({
owner,
repo,
issue_number: issueNumber,
assignees: assignees,
});
}