forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (81 loc) · 3.11 KB
/
PR-assignment.yml
File metadata and controls
82 lines (81 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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@v3
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@v9
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@v9
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));
- name: Auto-label core PR
if: ${{ fromJSON(steps.get-props.outputs.result).isCoreChange }}
uses: actions/github-script@v8
with:
github-token: ${{ steps.token.outputs.token }}
script: |
const ghRequester = require('.github/workflows/scripts/ghRequest.js');
const request = ghRequester(github);
const prData = ${{ steps.get-props.outputs.result }};
await request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prData.pr,
labels: ['core'],
});