Skip to content

Assign Reviewer as Assignee #57

Assign Reviewer as Assignee

Assign Reviewer as Assignee #57

name: Assign Reviewer as Assignee
on:
pull_request_review:
types:
- submitted
permissions:
issues: write
pull-requests: write
jobs:
assign_reviewer:
runs-on: ubuntu-latest
steps:
- name: Assign the reviewer as assignee when changes are requested
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const reviewer = context.payload.review.user.login;
const prNumber = context.payload.pull_request.number;
const reviewState = context.payload.review.state;
if (reviewState === 'changes_requested') {
console.log(`Assigning reviewer: ${reviewer} to PR #${prNumber} as changes were requested.`);
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
assignees: [reviewer],
});
} else {
console.log(`No action taken. Review state is '${reviewState}'.`);
}