ci: remove reviewers when drafting or closing a PR

This commit is contained in:
Dundar Göc 2022-03-27 21:48:28 +02:00
parent 72652cbc46
commit da3ef2a538
2 changed files with 33 additions and 0 deletions

16
.github/scripts/remove-reviewers.js vendored Normal file
View File

@ -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
});
}

View File

@ -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})