-
Notifications
You must be signed in to change notification settings - Fork 15
92 lines (84 loc) · 3.19 KB
/
All.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
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
83
84
85
86
87
88
89
90
91
92
name: PR Automation Workflow
on:
pull_request:
types: [opened, closed, labeled, review_requested, review_request_removed, synchronize]
pull_request_review:
types: [submitted]
jobs:
automate-pr-labels-and-review:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Add "⇵ 通过" label when approved by WForst-Breeze
if: github.event.review.state == 'approved' && github.event.review.user.login == 'WForst-Breeze'
uses: actions/github-script@v5
with:
github-token: ${{ secrets.SHEEP }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['⇵ 通过']
})
- name: Approve PR when "⇵ 通过" label is added
if: github.event.label.name == '⇵ 通过'
uses: actions/github-script@v5
with:
github-token: ${{ secrets.SHEEP }}
script: |
github.rest.pulls.createReview({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
event: 'APPROVE'
})
- name: Close PR when "× 拒绝" label is added
if: github.event.label.name == '× 拒绝'
uses: actions/github-script@v5
with:
github-token: ${{ secrets.SHEEP }}
script: |
github.rest.pulls.update({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
})
- name: Add "× 拒绝" label when PR is closed
if: github.event_name == 'pull_request' && github.event.action == 'closed' && !github.event.pull_request.merged
uses: actions/github-script@v5
with:
github-token: ${{ secrets.SHEEP }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['× 拒绝']
})
- name: Request review from WForst-Breeze when PR is opened
if: github.event_name == 'pull_request' && github.event.action == 'opened'
uses: actions/github-script@v5
with:
github-token: ${{ secrets.SHEEP }}
script: |
github.rest.pulls.requestReviewers({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
reviewers: ['WForst-Breeze']
})
- name: Add "√ 完成" label when PR is merged
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged
uses: actions/github-script@v5
with:
github-token: ${{ secrets.SHEEP }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['√ 完成']
})