From 9758be5c718b9ddc596b57c47f831237469289e9 Mon Sep 17 00:00:00 2001 From: Sambhav Gupta Date: Sun, 17 Nov 2024 11:35:31 +0530 Subject: [PATCH] initial commit --- .github/workflows/notify-triager.yml | 65 +++++++++++++++------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/.github/workflows/notify-triager.yml b/.github/workflows/notify-triager.yml index bcdd6ef3d352..49b65fdc95b8 100644 --- a/.github/workflows/notify-triager.yml +++ b/.github/workflows/notify-triager.yml @@ -48,51 +48,58 @@ jobs: files: | !**.md - - name: Extract Doc Triage Maintainers id: doc-triager run: | - docTriagers=$(grep '^#' CODEOWNERS | tail -n 2 | head -n 1) - echo "docTriagers: $docTriagers" - prefix="#docTriagers: " - docTriagers=${docTriagers#$prefix} + docTriagers=$(grep '^#docTriagers' CODEOWNERS | sed 's/#docTriagers: //') + if [ -z "$docTriagers" ]; then + echo "No doc triagers found" + fi echo "docTriagers=$docTriagers" >> $GITHUB_ENV - name: Extract Code Triage Maintainers id: code-triager run: | - codeTriagers=$(grep '^#' CODEOWNERS | tail -n 1) - echo "codeTriagers: $codeTriagers" - prefix="#codeTriagers: " - codeTriagers=${codeTriagers#$prefix} + codeTriagers=$(grep '^#codeTriagers' CODEOWNERS | sed 's/#codeTriagers: //') + if [ -z "$codeTriagers" ]; then + echo "No code triagers found" + fi echo "codeTriagers=$codeTriagers" >> $GITHUB_ENV - name: Add Reviewers for code files if: steps.check-merge-branch.outputs.isMergeCommit == 'false' && steps.non-md-pr-changes.outputs.any_changed == 'true' run: | IFS=' ' read -r -a codeTriagers <<< "${{ env.codeTriagers }}" - reviewers=$(printf ', "%s"' "${codeTriagers[@]}") - reviewers=[${reviewers:2}] - curl \ - -X POST \ - -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \ - -d "{ - \"reviewers\": $reviewers - }" + if [ ${#codeTriagers[@]} -gt 0 ]; then + reviewers=$(printf ', "%s"' "${codeTriagers[@]}") + reviewers="[${reviewers:2}]" + curl \ + -X POST \ + -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \ + -d "{ + \"reviewers\": $reviewers + }" + else + echo "No code triagers found, skipping review assignment" + fi - name: Add Reviewers for doc files if: steps.check-merge-branch.outputs.isMergeCommit == 'false' && steps.md-pr-changes.outputs.any_changed == 'true' run: | IFS=' ' read -r -a docTriagers <<< "${{ env.docTriagers }}" - reviewers=$(printf ', "%s"' "${docTriagers[@]}") - reviewers=[${reviewers:2}] - curl \ - -X POST \ - -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \ - -d "{ - \"reviewers\": $reviewers - }" + if [ ${#docTriagers[@]} -gt 0 ]; then + reviewers=$(printf ', "%s"' "${docTriagers[@]}") + reviewers="[${reviewers:2}]" + curl \ + -X POST \ + -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \ + -d "{ + \"reviewers\": $reviewers + }" + else + echo "No doc triagers found, skipping review assignment" + fi \ No newline at end of file