Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(gha): remove use of actions-ecosystem/action-remove-labels #1914

Merged
merged 3 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/reusable.yml
with:
label-name: "waiting-response"
remove-stale:
uses: ./.github/workflows/reusable.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
})