Create remove-labels-assignees-on-close.yml
This commit is contained in:
38
.github/workflows/remove-labels-assignees-on-close.yml
vendored
Normal file
38
.github/workflows/remove-labels-assignees-on-close.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
name: Remove Labels and Assignees on Issue Close
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [closed]
|
||||
pull_request:
|
||||
types: [closed]
|
||||
|
||||
jobs:
|
||||
remove-labels-and-assignees:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Remove all labels and assignees
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
const issue = context.payload.issue || context.payload.pull_request;
|
||||
const repo = context.repo;
|
||||
|
||||
// Remove all labels
|
||||
await github.rest.issues.removeAllLabels({
|
||||
owner: repo.owner,
|
||||
repo: repo.name,
|
||||
issue_number: issue.number
|
||||
});
|
||||
|
||||
// Remove all assignees
|
||||
if (issue.assignees && issue.assignees.length > 0) {
|
||||
await github.rest.issues.removeAssignees({
|
||||
owner: repo.owner,
|
||||
repo: repo.name,
|
||||
issue_number: issue.number,
|
||||
assignees: issue.assignees.map(assignee => assignee.login)
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`Removed all labels and assignees from issue/PR #${issue.number}`);
|
||||
Reference in New Issue
Block a user