Assign Reviewer as Assignee #57
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: 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}'.`); | |
} |