Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions .github/workflows/main-reviewer.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Main Reviewer Checklist
name: Reviewer Checklist

on:
pull_request:
types: [assigned]
types: [unassigned, assigned, review_requested, review_request_removed]

jobs:
checklist:
Expand All @@ -13,20 +13,48 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

# Step 2: Extract the main reviewer (assignee) and PR details
# Step 2: Extract the assignee, reviewers, and PR details
- name: Extract PR details
id: pr_details
run: |
echo "ASSIGNEE=$(jq -r '.assignee.login' < $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
ASSIGNEE=$(jq -r '.assignee.login // ""' < $GITHUB_EVENT_PATH)
REVIEWERS=$(jq -r '.pull_request.requested_reviewers[].login // ""' < $GITHUB_EVENT_PATH)
echo "ASSIGNEE=$ASSIGNEE" >> $GITHUB_ENV
echo "REVIEWERS=$REVIEWERS" >> $GITHUB_ENV

# Step 3: Replace the placeholder in the checklist template
# Step 3: Determine the checklist template or skip posting
- name: Determine checklist template or skip
id: checklist_template
run: |
ASSIGNEE="${{ env.ASSIGNEE }}"
REVIEWERS="${{ env.REVIEWERS }}"

# If assignee is also a reviewer, use main_rev_checklist.md
if [[ "$REVIEWERS" == *"$ASSIGNEE"* && -n "$ASSIGNEE" ]]; then
echo "TEMPLATE=main_rev_checklist.md" >> $GITHUB_ENV
echo "POST_CHECKLIST=true" >> $GITHUB_ENV
# If assignee is set but NOT a reviewer, skip posting
elif [[ -n "$ASSIGNEE" && "$REVIEWERS" != *"$ASSIGNEE"* ]]; then
echo "POST_CHECKLIST=false" >> $GITHUB_ENV
# If there are reviewers (and assignee is empty or not a reviewer), use rev_checklist.md
elif [[ -n "$REVIEWERS" ]]; then
echo "TEMPLATE=rev_checklist.md" >> $GITHUB_ENV
echo "POST_CHECKLIST=true" >> $GITHUB_ENV
else
echo "POST_CHECKLIST=false" >> $GITHUB_ENV
fi

# Step 4: Replace the placeholder in the selected checklist template
- name: Replace reviewer name in checklist template
if: env.POST_CHECKLIST == 'true'
run: |
TEMPLATE=${{ env.TEMPLATE }}
ASSIGNEE=${{ env.ASSIGNEE }}
sed "s/__MAINREV__/$ASSIGNEE/g" .github/workflows/main_rev_checklist.md > filled_checklist.md
sed "s/__REV__/$ASSIGNEE/g" .github/workflows/$TEMPLATE > filled_checklist.md

# Step 4: Post the filled checklist as a comment
# Step 5: Post the filled checklist as a comment
- name: Post checklist as a comment
if: env.POST_CHECKLIST == 'true'
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main_rev_checklist.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Hello @__MAINREV__!
Hello @__REV__!

You've been assigned to this PR, which means that you've been nominated Main Reviewer! Lucky you!

Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/rev_checklist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Hello @__REV__!

You've been assigned to this PR, which means that you've been nominated as reviewer! You are a supporting reviewer, not the main reviewer - the main reviewer has more responsibilities than you (lucky them) but your review is still important.

If you have any doubt, check [this section on reviewing](https://phys2bids.readthedocs.io/en/latest/contributorfile.html#reviewing)

Checklist
- [ ] one
- [ ] two
- [ ] three

Thank you!
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ This workflow automatically assigns labels to a PR if the PR edits a specific fi
### 4 - welcome bot app, defined in [config.yml](https://github.com/physiopy/physiopy-test-workflows/blob/master/.github/config.yml)
This bot automatically posts welcome and thank you messages when a contributor posts their first issue, first PR, and merges first PR. This is a nice way to welcome and thank new contributors, but also acts as an opportunity to direct them towards the relevant contributor guidelines, as needed.

### 5 - main reviewer checklist (desc to come)

Example:

![image](https://github.com/user-attachments/assets/b5fa9565-851b-4c0a-8b97-e9e414276b7d)
Expand Down
Loading