Hansimov commited on
Commit
57970d3
1 Parent(s): 5c69aa3

:gem: [Feature] Auto remove in-progress label when issue closed

Browse files
.github/workflows/remove_issue_label.yml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Remove label "in-progress" when an issue is closed
2
+ name: Remove issue label
3
+
4
+ on:
5
+ issues:
6
+ types: [closed]
7
+
8
+ jobs:
9
+ remove_label:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Remove label
13
+ uses: actions/github-script@v6
14
+ with:
15
+ github-token: ${{secrets.GITHUB_TOKEN}}
16
+ script: |
17
+ const issue_number = context.issue.number;
18
+ const owner = context.repo.owner;
19
+ const repo = context.repo.repo;
20
+ const labelToRemove = "in-progress";
21
+
22
+ // Fetch all labels for the issue
23
+ const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
24
+ issue_number: issue_number,
25
+ owner: owner,
26
+ repo: repo
27
+ });
28
+
29
+ // Check if the label exists on the issue
30
+ const hasLabel = currentLabels.some(label => label.name === labelToRemove);
31
+
32
+ // If the label exists, remove it
33
+ if (hasLabel) {
34
+ await github.rest.issues.removeLabel({
35
+ issue_number: issue_number,
36
+ owner: owner,
37
+ repo: repo,
38
+ name: labelToRemove
39
+ });
40
+ }