From c90c814158ab89c8874e613a3655b4ce88892329 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Mon, 22 Jul 2024 17:16:57 -0400 Subject: [PATCH] .github/workflows: Add PR reviewer automation --- .github/workflows/request-reviews.yml | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/request-reviews.yml diff --git a/.github/workflows/request-reviews.yml b/.github/workflows/request-reviews.yml new file mode 100644 index 000000000000..ed5ce775b145 --- /dev/null +++ b/.github/workflows/request-reviews.yml @@ -0,0 +1,47 @@ +name: Add Pull Request Reviewers + +on: + pull_request: + branches: + - master + types: [opened, ready_for_review, reopened] + +env: + GET_MAINTAINER_REL_PATH: "BaseTools/Scripts/GetMaintainer.py" + +jobs: + auto-request-review: + name: Add Pull Request Reviewers + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install requests library + run: pip install requests + + - name: Add Reviewers to Pull Request + shell: python + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + ORG_NAME: ${{ github.repository_owner }} + PR_NUMBER: ${{ github.event.number}} + REPO_NAME: ${{ github.repository }} + WORKSPACE_PATH: ${{ github.workspace }} + run: | + import os + import sys + sys.path.append(os.environ['WORKSPACE_PATH']) + from BaseTools.Scripts import GitHub + + reviewers = GitHub.get_reviewers_for_current_branch(WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH) + if not reviewers: + print("::notice title=No Reviewers Found!::No reviewers found for this PR.") + sys.exit(1) + + print(f"::notice title=Reviewer List::Reviewers found for PR {os.environ['GITHUB_OUTPUT']}:\n{', '.join(reviewers)}")