diff --git a/.github/workflows/close-if-no-reply.yml b/.github/workflows/close-if-no-reply.yml index 16b964b60..713dea899 100644 --- a/.github/workflows/close-if-no-reply.yml +++ b/.github/workflows/close-if-no-reply.yml @@ -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." diff --git a/.github/workflows/remove-labels-when-issue-gets-closed.yml b/.github/workflows/remove-labels-when-issue-gets-closed.yml new file mode 100644 index 000000000..d6881341e --- /dev/null +++ b/.github/workflows/remove-labels-when-issue-gets-closed.yml @@ -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.'); + } \ No newline at end of file