Skip to content

Commit

Permalink
tooling - update reviewer assign to only do it when changes are reque…
Browse files Browse the repository at this point in the history
…sted (hashicorp#28388)
  • Loading branch information
katbyte authored Dec 26, 2024
1 parent 2129b95 commit 1eb1d0c
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions .github/workflows/auto-assign-reviewers-to-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,31 @@ on:
types:
- submitted

permissions:
issues: write
pull-requests: write

jobs:
assign_reviewer:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Assign the reviewer as assignee
- 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;
console.log(`Assigning reviewer: ${reviewer} to PR #${prNumber}`);
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
assignees: [reviewer],
});
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}'.`);
}

0 comments on commit 1eb1d0c

Please sign in to comment.