From d9ade05cba8516417640975587baa3cc5c7e889f Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Wed, 10 Aug 2022 13:42:11 +0300 Subject: [PATCH] remove assignee on reopen --- .github/workflows/assign-on-label.yml | 2 +- ...els-on-reopen.yml => change-on-reopen.yml} | 23 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) rename .github/workflows/{rm-labels-on-reopen.yml => change-on-reopen.yml} (51%) diff --git a/.github/workflows/assign-on-label.yml b/.github/workflows/assign-on-label.yml index 62ac5f136aa..b7402b1c13c 100644 --- a/.github/workflows/assign-on-label.yml +++ b/.github/workflows/assign-on-label.yml @@ -5,7 +5,7 @@ on: types: [labeled] jobs: - remove_label: + assign: runs-on: ubuntu-latest steps: - uses: actions/github-script@v6 diff --git a/.github/workflows/rm-labels-on-reopen.yml b/.github/workflows/change-on-reopen.yml similarity index 51% rename from .github/workflows/rm-labels-on-reopen.yml rename to .github/workflows/change-on-reopen.yml index 436d063b68e..5841544fab5 100644 --- a/.github/workflows/rm-labels-on-reopen.yml +++ b/.github/workflows/change-on-reopen.yml @@ -1,14 +1,14 @@ -name: "Remove 'Resolved' and 'Cannot reproduce' labels when issue is reopened" +name: "Remove 'A: Resolved', 'A: Cannot reproduce' labels and Assigne when issue is reopened" on: issues: types: [reopened] jobs: - remove_label: + remove_labels_assignees: runs-on: ubuntu-latest steps: - - uses: actions/github-script@v3 + - uses: actions/github-script@v6 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -16,7 +16,7 @@ jobs: const repo = context.repo.repo; const issueNumber = context.issue.number; - var issueLabelsRaw = await github.issues.listLabelsOnIssue({ + var issueLabelsRaw = await github.rest.issues.listLabelsOnIssue({ owner, repo, issue_number: issueNumber, @@ -27,7 +27,8 @@ jobs: const labelsToRemove = [ 'A: Resolved', 'A: Cannot reproduce' ]; for (let label of labelsToRemove) { if (issueLabels.includes(label)) { - github.issues.removeLabel({ + console.log(`Removing ${label} from #${issueNumber}`); + await github.rest.issues.removeLabel({ owner, repo, issue_number: issueNumber, @@ -36,3 +37,15 @@ jobs: } } + 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, + }); + } + +