-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(gha): remove use of
actions-ecosystem/action-remove-labels
(#…
- Loading branch information
1 parent
91adcfc
commit fdea14a
Showing
2 changed files
with
60 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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@v6 | ||
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 | ||
}) |