Demo PR #11
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Reviewer Checklist | |
| on: | |
| pull_request: | |
| types: [assigned, review_requested, review_request_removed] | |
| jobs: | |
| checklist: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Check out the repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| # Step 2: Extract the assignee, reviewers, and PR details | |
| - name: Extract PR details | |
| id: pr_details | |
| run: | | |
| 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: Determine the checklist template to use | |
| - name: Determine checklist template | |
| id: checklist_template | |
| run: | | |
| ASSIGNEE=${{ env.ASSIGNEE }} | |
| REVIEWERS=${{ env.REVIEWERS }} | |
| if [[ "$REVIEWERS" == *"$ASSIGNEE"* && -n "$ASSIGNEE" ]]; then | |
| echo "TEMPLATE=main_rev_checklist.md" >> $GITHUB_ENV | |
| else | |
| echo "TEMPLATE=rev_checklist.md" >> $GITHUB_ENV | |
| # Step 4: Replace the placeholder in the selected checklist template | |
| - name: Replace reviewer name in checklist template | |
| run: | | |
| TEMPLATE=${{ env.TEMPLATE }} | |
| ASSIGNEE=${{ env.ASSIGNEE }} | |
| sed "s/@__REV__/$ASSIGNEE/g" .github/workflows/$TEMPLATE > filled_checklist.md | |
| # Step 5: Post the filled checklist as a comment | |
| - name: Post checklist as a comment | |
| uses: peter-evans/create-or-update-comment@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body-path: filled_checklist.md |