Skip to content

docs: Component Rules #495

docs: Component Rules

docs: Component Rules #495

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