From ff5fb747b4262a3b4a08115c0cc5d37abe9c6e18 Mon Sep 17 00:00:00 2001 From: Rohit <108233235+TRohit20@users.noreply.github.com> Date: Sat, 16 Mar 2024 17:41:40 +0530 Subject: [PATCH] fix: add workflow to notify docs triagers on relevant PRs (#2660) Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com>%0ACo-authored-by: akshatnema %0ACo-authored-by: Quetzalli %0ACo-authored-by: Ansh Goyal --- .github/workflows/notify-triager.yml | 75 ++++++++++++++++++++++++++++ CODEOWNERS | 6 ++- 2 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/notify-triager.yml diff --git a/.github/workflows/notify-triager.yml b/.github/workflows/notify-triager.yml new file mode 100644 index 00000000000..4697775a3dc --- /dev/null +++ b/.github/workflows/notify-triager.yml @@ -0,0 +1,75 @@ +name: Notify Triagers + +on: + pull_request_target: + types: [opened, reopened, synchronize, edited, ready_for_review] + +jobs: + Notify-triagers: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4.1.1 + + - name: Check PR Changes for .md files + id: md-pr-changes + uses: tj-actions/changed-files@aa08304bd477b800d468db44fe10f6c61f7f7b11 # version 42.1.0 https://github.com/tj-actions/changed-files/releases/tag/v42.1.0 + with: + files: | + **.md + + - name: Check PR Changes for non-.md files + id: non-md-pr-changes + uses: tj-actions/changed-files@aa08304bd477b800d468db44fe10f6c61f7f7b11 # version 42.1.0 https://github.com/tj-actions/changed-files/releases/tag/v42.1.0 + with: + 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} + 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} + echo "codeTriagers=$codeTriagers" >> $GITHUB_ENV + + - name: Add Reviewers for code files + if: 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 + }" + + - name: Add Reviewers for doc files + if: 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 + }" diff --git a/CODEOWNERS b/CODEOWNERS index 6bf196d558a..ea61b1d1d70 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -5,12 +5,14 @@ # For more details, read the following article on GitHub: https://help.github.com/articles/about-codeowners/. # The default owners are automatically added as reviewers when you open a pull request unless different owners are specified in the file. -* @derberg @akshatnema @magicmatatjahu @anshgoyalevil @sambhavgupta0705 @mayaleeeee @asyncapi-bot-eve +* @derberg @akshatnema @magicmatatjahu @anshgoyalevil @mayaleeeee @asyncapi-bot-eve # All .md files -*.md @alequetzalli @octonawish-akcodes @BhaswatiRoy @TRohit20 @VaishnaviNandakumar @Arya-Gupta @J0SAL @asyncapi-bot-eve +*.md @alequetzalli @asyncapi-bot-eve pages/blog/*.md @thulieblack @alequetzalli pages/community/*.md @thulieblack @alequetzalli README.md @alequetzalli @derberg @akshatnema @magicmatatjahu @mayaleeeee @asyncapi-bot-eve +#docTriagers: TRohit20 octonawish-akcodes BhaswatiRoy VaishnaviNandakumar Arya-Gupta J0SAL +#codeTriagers: sambhavgupta0705