-
Notifications
You must be signed in to change notification settings - Fork 2
54 lines (49 loc) ยท 1.8 KB
/
auto-assign-reviewers.yml
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
name: 'Auto Assign Reviewers'
on:
pull_request:
types: [opened, labeled]
jobs:
assign_reviewers:
runs-on: ubuntu-latest
steps:
- name: 'Set Assignee to Author'
uses: actions/github-script@v6
with:
script: |
if (context.payload.pull_request) {
await github.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
assignees: [context.payload.pull_request.user.login],
});
} else {
console.log('No pull_request data found in context.payload');
}
- name: 'Add "ํ์ธ ์์ฒญ" Label if not present'
uses: actions/github-script@v6
id: label_check
with:
script: |
const labels = context.payload.pull_request.labels || [];
if (!labels.some(label => label.name === 'ํ์ธ ์์ฒญ')) {
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ['ํ์ธ ์์ฒญ'],
});
}
- name: 'Determine Number of Reviewers'
id: determine_reviewers
uses: actions/github-script@v6
with:
script: |
const targetBranch = context.payload.pull_request.base.ref;
return targetBranch === 'main' ? 3 : 2;
- name: 'Assign Reviewers'
uses: kentaro-m/[email protected]
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
configuration-path: '.github/auto_assign_config.yml'
numberOfReviewers: ${{ steps.determine_reviewers.outputs.result }}