mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-10-29 11:49:33 +00:00
Add workflow to remove labels when an issue gets closed (#7910)
This commit is contained in:
parent
705be4814d
commit
5e1ec5fc2e
4
.github/workflows/close-if-no-reply.yml
vendored
4
.github/workflows/close-if-no-reply.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v5
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
days-before-stale: 7
|
||||
days-before-close: 7
|
||||
@ -20,7 +20,7 @@ jobs:
|
||||
stale-pr-label: 'Needs: Reply still'
|
||||
stale-issue-message: "This issue will be closed when we don't get a reply within 7 days."
|
||||
stale-pr-message: "This PR will be closed when we don't get a reply within 7 days."
|
||||
labels-to-remove-when-unstale: 'Needs: Reply'
|
||||
labels-to-remove-when-stale: 'Needs: Reply'
|
||||
close-issue-label: "Close reason: No reply"
|
||||
close-pr-label: "Close reason: No reply"
|
||||
close-issue-message: "This issue was closed because we didn't get a reply for 14 days."
|
||||
|
||||
50
.github/workflows/remove-labels-when-issue-gets-closed.yml
vendored
Normal file
50
.github/workflows/remove-labels-when-issue-gets-closed.yml
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
name: Remove labels when issue gets closed
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [closed]
|
||||
|
||||
jobs:
|
||||
remove-labels:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Remove labels from closed issue
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const labelsToRemove = ['Needs: Triage', 'Needs: Decision', 'Needs: Reply still'];
|
||||
const issue = context.payload.issue;
|
||||
|
||||
// Get current labels on the issue
|
||||
const currentLabels = issue.labels.map(label => label.name);
|
||||
|
||||
// Create updated label list by filtering out the labels to remove
|
||||
const updatedLabels = currentLabels.filter(label =>
|
||||
!labelsToRemove.includes(label)
|
||||
);
|
||||
|
||||
// Check if any labels were actually removed
|
||||
const removedLabels = currentLabels.filter(label =>
|
||||
labelsToRemove.includes(label)
|
||||
);
|
||||
|
||||
if (removedLabels.length > 0) {
|
||||
console.log(`Removing labels: ${removedLabels.join(', ')}`);
|
||||
console.log(`Updated label list: ${updatedLabels.join(', ') || 'No labels remaining'}`);
|
||||
|
||||
try {
|
||||
// Update the issue with the new label list in a single operation
|
||||
await github.rest.issues.update({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
labels: updatedLabels
|
||||
});
|
||||
console.log(`Successfully updated labels. Removed: ${removedLabels.join(', ')}`);
|
||||
} catch (error) {
|
||||
console.log(`Failed to update labels: ${error.message}`);
|
||||
}
|
||||
} else {
|
||||
console.log('No target labels found on this issue to remove.');
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user