Skip to content

Commit

Permalink
chore: update choosing reviewers
Browse files Browse the repository at this point in the history
  • Loading branch information
stardustmeg committed Apr 25, 2024
1 parent a4724b0 commit 5a53437
Showing 1 changed file with 33 additions and 48 deletions.
81 changes: 33 additions & 48 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,60 +39,45 @@ jobs:
run: |
echo "PR Author: ${{ steps.pr_author.outputs.author }}"
- name: Select First Reviewer
id: select_first_reviewer
if: github.actor != steps.pr_author.outputs.author # Exclude the author
- name: Assign Reviewers
id: assign_reviewers
run: |
author="${{ steps.pr_author.outputs.author }}"
all_users=("stardustmeg" "Kleostro" "YulikK")
# Exclude the PR author from the list of potential reviewers
potential_reviewers=()
for user in "${all_users[@]}"; do
if [[ "$user" != "$author" ]]; then
potential_reviewers+=("$user")
fi
done
echo "Potential Reviewers: ${potential_reviewers[@]}"
if [[ ${#potential_reviewers[@]} -gt 0 ]]; then
# Select the first reviewer from the potential reviewers list
first_reviewer="${potential_reviewers[0]}"
echo "::set-output name=first_reviewer::${first_reviewer}"
if [[ "$author" == "stardustmeg" ]]; then
first_reviewer="Kleostro"
second_reviewer="YulikK"
elif [[ "$author" == "Kleostro" ]]; then
first_reviewer="stardustmeg"
second_reviewer="YulikK"
elif [[ "$author" == "YulikK" ]]; then
first_reviewer="stardustmeg"
second_reviewer="Kleostro"
else
echo "No potential reviewers found."
echo "Author not found."
exit 1
fi
echo "::set-output name=first_reviewer::${first_reviewer}"
echo "::set-output name=second_reviewer::${second_reviewer}"
- name: Debug First Reviewer
- name: Debug Reviewers
run: |
echo "First Reviewer: ${{ steps.select_first_reviewer.outputs.first_reviewer }}"
echo "First Reviewer: ${{ steps.assign_reviewers.outputs.first_reviewer }}"
echo "Second Reviewer: ${{ steps.assign_reviewers.outputs.second_reviewer }}"
- name: Select Second Reviewer
id: select_second_reviewer
- name: Request First Reviewer
if: github.actor != steps.pr_author.outputs.author # Exclude the author
run: |
author="${{ steps.pr_author.outputs.author }}"
all_users=("stardustmeg" "Kleostro" "YulikK")
# Exclude the PR author and the first reviewer from the list of potential reviewers
potential_reviewers=()
for user in "${all_users[@]}"; do
if [[ "$user" != "$author" && "$user" != "${{ steps.select_first_reviewer.outputs.first_reviewer }}" ]]; then
potential_reviewers+=("$user")
fi
done
echo "Potential Reviewers: ${potential_reviewers[@]}"
if [[ ${#potential_reviewers[@]} -gt 0 ]]; then
# Select the second reviewer from the potential reviewers list
second_reviewer="${potential_reviewers[0]}"
echo "::set-output name=second_reviewer::${second_reviewer}"
else
echo "No potential reviewers found."
fi
uses: octokit/[email protected]
with:
route: POST /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers
mediaType: '{"previews":["luke-cage"]}'
token: ${{ secrets.GITHUB_TOKEN }}
reviewers: ${{ steps.assign_reviewers.outputs.first_reviewer }}

- name: Debug Second Reviewer
run: |
echo "Second Reviewer: ${{ steps.select_second_reviewer.outputs.second_reviewer }}"
- name: Request Second Reviewer
if: github.actor != steps.pr_author.outputs.author # Exclude the author
uses: octokit/[email protected]
with:
route: POST /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers
mediaType: '{"previews":["luke-cage"]}'
token: ${{ secrets.GITHUB_TOKEN }}
reviewers: ${{ steps.assign_reviewers.outputs.second_reviewer }}

0 comments on commit 5a53437

Please sign in to comment.