diff options
author | Dundar Göc <gocdundar@gmail.com> | 2022-03-27 21:48:28 +0200 |
---|---|---|
committer | Dundar Göc <gocdundar@gmail.com> | 2022-03-27 22:35:26 +0200 |
commit | da3ef2a53801c6b4dea186000826e91de8494e1c (patch) | |
tree | 0dedeee59083a1152e59b5a4cce063dbf45197b2 | |
parent | 72652cbc46f568128bfc296ba63fb2d26941da8e (diff) | |
download | rneovim-da3ef2a53801c6b4dea186000826e91de8494e1c.tar.gz rneovim-da3ef2a53801c6b4dea186000826e91de8494e1c.tar.bz2 rneovim-da3ef2a53801c6b4dea186000826e91de8494e1c.zip |
ci: remove reviewers when drafting or closing a PR
-rw-r--r-- | .github/scripts/remove-reviewers.js | 16 | ||||
-rw-r--r-- | .github/workflows/remove-reviewers-on-draft.yml | 17 |
2 files changed, 33 insertions, 0 deletions
diff --git a/.github/scripts/remove-reviewers.js b/.github/scripts/remove-reviewers.js new file mode 100644 index 0000000000..631f08e57d --- /dev/null +++ b/.github/scripts/remove-reviewers.js @@ -0,0 +1,16 @@ +module.exports = async ({github, context}) => { + const requestedReviewers = await github.rest.pulls.listRequestedReviewers({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number + }); + + const reviewers = requestedReviewers.data.users.map(e => e.login) + + github.rest.pulls.removeRequestedReviewers({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + reviewers: reviewers + }); +} diff --git a/.github/workflows/remove-reviewers-on-draft.yml b/.github/workflows/remove-reviewers-on-draft.yml new file mode 100644 index 0000000000..64474618b8 --- /dev/null +++ b/.github/workflows/remove-reviewers-on-draft.yml @@ -0,0 +1,17 @@ +name: "Remove reviewers" +on: + pull_request_target: + types: [converted_to_draft, closed] +jobs: + remove-reviewers: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/checkout@v2 + - name: 'Remove reviewers' + uses: actions/github-script@v6 + with: + script: | + const script = require('./.github/scripts/remove-reviewers.js') + await script({github, context}) |