Skip to content

Commit 0132137

Browse files
authored
Refactor checklist template determination logic
1 parent a6e41f1 commit 0132137

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

.github/workflows/main-reviewer.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,39 @@ jobs:
2222
echo "ASSIGNEE=$ASSIGNEE" >> $GITHUB_ENV
2323
echo "REVIEWERS=$REVIEWERS" >> $GITHUB_ENV
2424
25-
# Step 3: Determine the checklist template to use
26-
- name: Determine checklist template
25+
# Step 3: Determine the checklist template or skip posting
26+
- name: Determine checklist template or skip
2727
id: checklist_template
2828
run: |
29-
ASSIGNEE=${{ env.ASSIGNEE }}
30-
REVIEWERS=${{ env.REVIEWERS }}
29+
ASSIGNEE="${{ env.ASSIGNEE }}"
30+
REVIEWERS="${{ env.REVIEWERS }}"
31+
32+
# If assignee is also a reviewer, use main_rev_checklist.md
3133
if [[ "$REVIEWERS" == *"$ASSIGNEE"* && -n "$ASSIGNEE" ]]; then
3234
echo "TEMPLATE=main_rev_checklist.md" >> $GITHUB_ENV
33-
else
35+
echo "POST_CHECKLIST=true" >> $GITHUB_ENV
36+
# If assignee is set but NOT a reviewer, skip posting
37+
elif [[ -n "$ASSIGNEE" && "$REVIEWERS" != *"$ASSIGNEE"* ]]; then
38+
echo "POST_CHECKLIST=false" >> $GITHUB_ENV
39+
# If there are reviewers (and assignee is empty or not a reviewer), use rev_checklist.md
40+
elif [[ -n "$REVIEWERS" ]]; then
3441
echo "TEMPLATE=rev_checklist.md" >> $GITHUB_ENV
42+
echo "POST_CHECKLIST=true" >> $GITHUB_ENV
43+
else
44+
echo "POST_CHECKLIST=false" >> $GITHUB_ENV
3545
fi
3646
3747
# Step 4: Replace the placeholder in the selected checklist template
3848
- name: Replace reviewer name in checklist template
49+
if: env.POST_CHECKLIST == 'true'
3950
run: |
4051
TEMPLATE=${{ env.TEMPLATE }}
4152
ASSIGNEE=${{ env.ASSIGNEE }}
4253
sed "s/__REV__/$ASSIGNEE/g" .github/workflows/$TEMPLATE > filled_checklist.md
4354
4455
# Step 5: Post the filled checklist as a comment
4556
- name: Post checklist as a comment
57+
if: env.POST_CHECKLIST == 'true'
4658
uses: peter-evans/create-or-update-comment@v3
4759
with:
4860
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)