File tree Expand file tree Collapse file tree 2 files changed +57
-38
lines changed Expand file tree Collapse file tree 2 files changed +57
-38
lines changed Original file line number Diff line number Diff line change
1
+ name : Remove Labels and Assignees on Issue Close
2
+
3
+ on :
4
+ issues :
5
+ types : [closed]
6
+ pull_request :
7
+ types : [closed]
8
+
9
+ jobs :
10
+ remove-labels-and-assignees :
11
+ runs-on : ubuntu-latest
12
+ steps :
13
+ - name : Remove labels and assignees
14
+ uses : actions/github-script@v7
15
+ with :
16
+ github-token : ${{ secrets.GITHUB_TOKEN }}
17
+ script : |
18
+ const issue = context.payload.issue || context.payload.pull_request;
19
+ const { owner, repo } = context.repo;
20
+
21
+ try {
22
+ const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
23
+ owner,
24
+ repo,
25
+ issue_number: issue.number
26
+ });
27
+
28
+ const labelsToKeep = currentLabels
29
+ .filter(label => label.name === '⏱︎ Stale')
30
+ .map(label => label.name);
31
+
32
+ await github.rest.issues.setLabels({
33
+ owner,
34
+ repo,
35
+ issue_number: issue.number,
36
+ labels: labelsToKeep
37
+ });
38
+ } catch (error) {
39
+ if (error.status !== 404) {
40
+ throw error;
41
+ }
42
+ }
43
+
44
+ if (issue.assignees && issue.assignees.length > 0) {
45
+ try {
46
+ await github.rest.issues.removeAssignees({
47
+ owner,
48
+ repo,
49
+ issue_number: issue.number,
50
+ assignees: issue.assignees.map(assignee => assignee.login)
51
+ });
52
+ } catch (error) {
53
+ if (error.status !== 404) {
54
+ throw error;
55
+ }
56
+ }
57
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments