-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update auto assign workflow (#28387)
* update auto assign workflow * update rest call and workflow name * move permission block
- Loading branch information
Showing
1 changed file
with
22 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
name: Auto Assign Reviewers as Assignees | ||
name: Assign Reviewer as Assignee | ||
|
||
on: | ||
pull_request: | ||
pull_request_review: | ||
types: | ||
- review_requested | ||
- review_request_removed | ||
- reopened | ||
- edited | ||
- synchronize | ||
- submitted | ||
|
||
jobs: | ||
auto_assign_reviewers: | ||
assign_reviewer: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
issues: write | ||
pull-requests: write | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get reviewers and assign them | ||
uses: peter-evans/review-assign-action@v1 | ||
- name: Assign the reviewer as assignee | ||
uses: actions/github-script@v6 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
reviewers: reviewers | ||
assignees: reviewers | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const reviewer = context.payload.review.user.login; | ||
const prNumber = context.payload.pull_request.number; | ||
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], | ||
}); |