Skip to content

www.jprime.jp

www.jprime.jp #6948

name: "Remove status labels and assignee when the issue is reopened"
on:
issues:
types: [reopened]
jobs:
remove_labels_assignees:
if: ${{ github.repository == 'AdguardTeam/AdguardFilters' }}
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const issueNumber = context.issue.number;
const issueLabelsRaw = await github.rest.issues.listLabelsOnIssue({
owner,
repo,
issue_number: issueNumber,
});
const issueLabels = issueLabelsRaw.data.map((el) => el.name);
const labelsToRemove = [ 'A: Resolved', 'A: Cannot reproduce', 'A: In progress', 'A: Waiting for data' ];
for (let label of labelsToRemove) {
if (issueLabels.includes(label)) {
console.log(`Removing ${label} from #${issueNumber}`);
await github.rest.issues.removeLabel({
owner,
repo,
issue_number: issueNumber,
name: label,
});
}
}
const assignees = context.payload.issue.assignees.map(a => a.login);
if (assignees.length !== 0) {
console.log(`Removing assignees ${assignees} from #${issueNumber}`);
await github.rest.issues.removeAssignees({
owner,
repo,
issue_number: issueNumber,
assignees: assignees,
});
}