1- name : Main Reviewer Checklist
1+ name : Reviewer Checklist
22
33on :
44 pull_request :
5- types : [assigned]
5+ types : [assigned, review_requested, review_request_removed ]
66
77jobs :
88 checklist :
@@ -13,19 +13,34 @@ jobs:
1313 - name : Checkout repository
1414 uses : actions/checkout@v3
1515
16- # Step 2: Extract the main reviewer ( assignee) and PR details
16+ # Step 2: Extract the assignee, reviewers, and PR details
1717 - name : Extract PR details
1818 id : pr_details
1919 run : |
20- echo "ASSIGNEE=$(jq -r '.assignee.login' < $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
20+ ASSIGNEE=$(jq -r '.assignee.login // ""' < $GITHUB_EVENT_PATH)
21+ REVIEWERS=$(jq -r '.pull_request.requested_reviewers[].login // ""' < $GITHUB_EVENT_PATH)
22+ echo "ASSIGNEE=$ASSIGNEE" >> $GITHUB_ENV
23+ echo "REVIEWERS=$REVIEWERS" >> $GITHUB_ENV
2124
22- # Step 3: Replace the placeholder in the checklist template
25+ # Step 3: Determine the checklist template to use
26+ - name : Determine checklist template
27+ id : checklist_template
28+ run : |
29+ ASSIGNEE=${{ env.ASSIGNEE }}
30+ REVIEWERS=${{ env.REVIEWERS }}
31+ if [[ "$REVIEWERS" == *"$ASSIGNEE"* && -n "$ASSIGNEE" ]]; then
32+ echo "TEMPLATE=main_rev_checklist.md" >> $GITHUB_ENV
33+ else
34+ echo "TEMPLATE=rev_checklist.md" >> $GITHUB_ENV
35+
36+ # Step 4: Replace the placeholder in the selected checklist template
2337 - name : Replace reviewer name in checklist template
2438 run : |
39+ TEMPLATE=${{ env.TEMPLATE }}
2540 ASSIGNEE=${{ env.ASSIGNEE }}
26- sed "s/__MAINREV__/$ASSIGNEE/g" .github/workflows/main_rev_checklist.md > filled_checklist.md
41+ sed "s/__MAINREV__/$ASSIGNEE/g" .github/workflows/$TEMPLATE > filled_checklist.md
2742
28- # Step 4 : Post the filled checklist as a comment
43+ # Step 5 : Post the filled checklist as a comment
2944 - name : Post checklist as a comment
3045 uses : peter-evans/create-or-update-comment@v3
3146 with :
0 commit comments