1 |
|
---|
2 | # This workflow automatically adds the appropriate reviewers to a pull request.
|
---|
3 | #
|
---|
4 | # The workflow directly reuses logic in the BaseTools/Scripts/GetMaintainer.py script
|
---|
5 | # to determine the appropriate reviewers, so it matches what a user would see running
|
---|
6 | # the script locally.
|
---|
7 | #
|
---|
8 | # Copyright (c) Microsoft Corporation.
|
---|
9 | # SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
10 |
|
---|
11 | name: Add Pull Request Reviewers
|
---|
12 |
|
---|
13 | on:
|
---|
14 | pull_request_target:
|
---|
15 | branches:
|
---|
16 | - master
|
---|
17 | types: [opened, ready_for_review, reopened, synchronize]
|
---|
18 |
|
---|
19 | env:
|
---|
20 | GET_MAINTAINER_REL_PATH: "BaseTools/Scripts/GetMaintainer.py"
|
---|
21 |
|
---|
22 | jobs:
|
---|
23 | auto-request-review:
|
---|
24 | name: Add Pull Request Reviewers
|
---|
25 | # Do not run on draft PRs and only run on PRs in the tianocore organization
|
---|
26 | if: ${{ github.event.pull_request.draft == false && github.repository_owner == 'tianocore' }}
|
---|
27 | runs-on: ubuntu-latest
|
---|
28 |
|
---|
29 | permissions:
|
---|
30 | contents: read
|
---|
31 | issues: write
|
---|
32 | pull-requests: write
|
---|
33 |
|
---|
34 | steps:
|
---|
35 | - name: Generate Token
|
---|
36 | id: generate-token
|
---|
37 | uses: actions/create-github-app-token@v1
|
---|
38 | with:
|
---|
39 | app-id: ${{ secrets.TIANOCORE_ASSIGN_REVIEWERS_APPLICATION_ID }}
|
---|
40 | private-key: ${{ secrets.TIANOCORE_ASSIGN_REVIEWERS_APPLICATION_PRIVATE_KEY }}
|
---|
41 |
|
---|
42 | # Reduce checkout time with sparse-checkout
|
---|
43 | # - .github: Contains the scripts to interact with Github and add reviewers
|
---|
44 | # - BaseTools/Scripts: Contains the GetMaintainer.py script
|
---|
45 | # - Maintainers.txt: Contains the list of maintainers for the repository
|
---|
46 | - name: Checkout repository
|
---|
47 | uses: actions/checkout@v4
|
---|
48 | with:
|
---|
49 | fetch-depth: 1
|
---|
50 | sparse-checkout: |
|
---|
51 | .github
|
---|
52 | BaseTools/Scripts
|
---|
53 | Maintainers.txt
|
---|
54 |
|
---|
55 | - name: Setup Python
|
---|
56 | uses: actions/setup-python@v5
|
---|
57 | with:
|
---|
58 | python-version: '3.x'
|
---|
59 | cache: 'pip'
|
---|
60 | cache-dependency-path: '.github/scripts/requirements.txt'
|
---|
61 |
|
---|
62 | - name: Install PIP Modules
|
---|
63 | run: pip install -r .github/scripts/requirements.txt --upgrade
|
---|
64 |
|
---|
65 | - name: Add Reviewers to Pull Request
|
---|
66 | env:
|
---|
67 | GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
---|
68 | ORG_NAME: ${{ github.repository_owner }}
|
---|
69 | PR_NUMBER: ${{ github.event.number}}
|
---|
70 | REPO_NAME: ${{ github.event.pull_request.base.repo.name }}
|
---|
71 | TARGET_BRANCH: ${{ github.event.pull_request.base.ref }}
|
---|
72 | WORKSPACE_PATH: ${{ github.workspace }}
|
---|
73 | run: python .github/scripts/RequestPrReviewers.py
|
---|