forked from hashicorp/terraform-provider-vsphere
-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (43 loc) · 1.73 KB
/
remove-issue-label.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
51
52
name: Remove specified label from issue
on:
# This file is reused, and called from other workflows
workflow_call:
inputs:
label-name:
required: true
type: string
jobs:
remove-label:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@e69ef5462fd455e02edcaf4dd7708eda96b9eda0 # v7.0.0
env:
REMOVE_LABEL: ${{ inputs.label-name }}
with:
script: |
const { REMOVE_LABEL } = process.env
console.log(`Attempting to remove label "${REMOVE_LABEL}"`)
const { data } = await github.rest.issues.listLabelsOnIssue({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})
// Return early if there are no labels
if (data.length == 0){
console.log(`Issue has no labels; not attempting to remove label "${REMOVE_LABEL}"`)
return
}
// Check if REMOVE_LABEL is present
const filteredData = data.filter(label => label.name == REMOVE_LABEL)
// Return early if filtering didn't identify the label as present
if (filteredData.length == 0){
console.log(`Label "${REMOVE_LABEL}" not found on issue; not attempting to remove it.`)
return
}
console.log(`Label "${REMOVE_LABEL}" found! Now deleting it from the issue...`)
await github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: REMOVE_LABEL
})