Check Approver #320
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check Approver | |
on: | |
pull_request_review: | |
types: [submitted] | |
permissions: read-all | |
jobs: | |
check_approver: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Approver | |
uses: actions/github-script@v7 | |
# Only run for external pull requests | |
if: github.event.pull_request.head.repo.fork | |
with: | |
script: | | |
const reviews = await github.rest.pulls.listReviews({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.payload.pull_request.number, | |
}); | |
const requiredReviewer = 'JayWhite2357'; | |
const approved = reviews.data.some(review => review.user.login === requiredReviewer && review.state === 'APPROVED'); | |
if (!approved) { | |
core.setFailed(`External pull request needs to be approved by ${requiredReviewer}.`); | |
} else { | |
console.log(`External pull request has been approved by ${requiredReviewer}.`); | |
} |