docs: ui.action_group #129
Workflow file for this run
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: 'Add docs reviewers' | |
on: | |
# Needs to be pull_request_target for pull-request write permission | |
pull_request_target: | |
paths: | |
- '**/docs/**/*.md' | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- ready_for_review | |
jobs: | |
add-docs-reviewers: | |
if: github.event.pull_request.draft == false | |
permissions: | |
pull-requests: write | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Add docs reviewers | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const reviewer = 'margaretkennedy'; | |
const pendingReviewers = await github.rest.pulls.listRequestedReviewers({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number | |
}); | |
const isPending = pendingReviewers.data?.users?.some(({ login }) => login === reviewer); | |
const reviews = await github.rest.pulls.listReviews({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number | |
}); | |
const isReviewed = reviews.data?.some(review => review.user.login === reviewer); | |
if (!isPending && !isReviewed) { | |
github.rest.pulls.requestReviewers({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number, | |
reviewers: [reviewer] | |
}); | |
} |