Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add Margaret as a reviewer automatically to any docs changes #778

Merged
merged 9 commits into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/request-docs-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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]
});
}
Loading