-
-
Notifications
You must be signed in to change notification settings - Fork 38
53 lines (47 loc) · 1.64 KB
/
assign-pr-to-creator.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
name: assign-pr-to-creator
on:
pull_request_target:
types: [opened]
permissions:
pull-requests: write
contents: read
issues: read
checks: read
actions: read
jobs:
assign-pr:
runs-on: ubuntu-latest
steps:
- name: 自动分配审查和受理至人民的勤务员
uses: actions/github-script@v7
with:
#github-token: ${{ secrets.BO_TOKEN }}
script: |
const prOwner = context.repo.owner;
const pullRequest = context.payload.pull_request;
const pull_number = pullRequest.number;
const prAuthor = pullRequest.user.login;
// 添加受理人
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pull_number,
assignees: [prOwner]
});
// 请求审阅
if (prOwner !== prAuthor) {
await github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull_number,
reviewers: [prOwner]
});
} else {
console.log(`跳过请求审阅,因为 PR 的作者是 ${prAuthor},也是仓库拥有者,无需审查!`);
}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pull_number,
body: `@${prAuthor} 你好,人民的勤务员将尽快审查合并此次请求!🚀 [自动回复,请勿跟帖] `
});