Assign PR reviewers #1
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: Assign PR reviewers | |
| on: | |
| workflow_run: | |
| workflows: | |
| - Compile dependencies.json for PR assignment checks | |
| types: | |
| - completed | |
| jobs: | |
| assign_reviewers: | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| name: Assign reviewers | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: master | |
| - name: Generate app token | |
| id: token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ vars.PR_BOT_ID }} | |
| private-key: ${{ secrets.PR_BOT_PEM }} | |
| - name: Download dependencies.json | |
| uses: ./.github/actions/unzip-artifact | |
| with: | |
| name: dependencies.json | |
| - name: Download PR info | |
| uses: ./.github/actions/unzip-artifact | |
| with: | |
| name: prInfo | |
| - name: Install s3 client | |
| run: | | |
| npm install @aws-sdk/client-s3 | |
| - name: Get PR properties | |
| id: get-props | |
| uses: actions/github-script@v8 | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ vars.PR_BOT_AWS_AK }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.PR_BOT_AWS_SAK }} | |
| DEPENDENCIES_JSON: ${{ runner.temp }}/artifacts/dependencies.json | |
| with: | |
| github-token: ${{ steps.token.outputs.token }} | |
| script: | | |
| const fs = require('fs'); | |
| const getProps = require('./.github/workflows/scripts/getPRProperties.js') | |
| const { prNo } = JSON.parse(fs.readFileSync('${{runner.temp}}/artifacts/prInfo.json').toString()); | |
| const props = await getProps({ | |
| github, | |
| context, | |
| prNo, | |
| reviewerTeam: '${{ vars.REVIEWER_TEAM }}', | |
| engTeam: '${{ vars.ENG_TEAM }}', | |
| authReviewTeam: '${{ vars.AUTH_REVIEWER_TEAM }}' | |
| }); | |
| console.log('PR properties:', JSON.stringify(props, null, 2)); | |
| return props; | |
| - name: Assign reviewers | |
| if: ${{ !fromJSON(steps.get-props.outputs.result).review.ok }} | |
| uses: actions/github-script@v8 | |
| with: | |
| github-token: ${{ steps.token.outputs.token }} | |
| script: | | |
| const assignReviewers = require('./.github/workflows/scripts/assignReviewers.js') | |
| const reviewers = await assignReviewers({github, context, prData: ${{ steps.get-props.outputs.result }} }); | |
| console.log('Assigned reviewers:', JSON.stringify(reviewers, null, 2)); |