Skip to content

Commit

Permalink
chore(gha): remove use of actions-ecosystem/action-remove-labels (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahFrench authored May 31, 2023
1 parent 91adcfc commit fdea14a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 11 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/issue-comment-created.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ on:
types: [created]

jobs:
issue_comment_triage:
runs-on: ubuntu-latest
steps:
- uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 # v1.3.0
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
labels: stale
- uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 # v1.3.0
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
labels: waiting-response
remove-foobar:
uses: ./.github/workflows/remove-issue-label.yml
with:
label-name: "waiting-response"
remove-stale:
uses: ./.github/workflows/remove-issue-label.yml
with:
label-name: "stale"
52 changes: 52 additions & 0 deletions .github/workflows/remove-issue-label.yml
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
})

0 comments on commit fdea14a

Please sign in to comment.