diff --git a/.github/workflows/main-reviewer.yml b/.github/workflows/main-reviewer.yml index 5ecd132..2b08138 100644 --- a/.github/workflows/main-reviewer.yml +++ b/.github/workflows/main-reviewer.yml @@ -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: @@ -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 }} diff --git a/.github/workflows/main_rev_checklist.md b/.github/workflows/main_rev_checklist.md index e2f828b..1f32c1e 100644 --- a/.github/workflows/main_rev_checklist.md +++ b/.github/workflows/main_rev_checklist.md @@ -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! diff --git a/.github/workflows/rev_checklist.md b/.github/workflows/rev_checklist.md new file mode 100644 index 0000000..975cd97 --- /dev/null +++ b/.github/workflows/rev_checklist.md @@ -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! diff --git a/README.md b/README.md index 2cdb3ee..a0042fa 100644 --- a/README.md +++ b/README.md @@ -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)