-
Notifications
You must be signed in to change notification settings - Fork 48
54 lines (44 loc) · 1.89 KB
/
pull_request_review.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: PullRequest | Review
on:
pull_request_review:
jobs:
approved:
name: Approved
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
const issue_number = context.payload.pull_request.number
const owner = context.repo.owner
const repo = context.repo.repo
const labelsToAdd = ['approved']
const labelsToRemove = ['to-review', 'changes-requested']
const currentLabels = await github.rest.issues.listLabelsOnIssue({ issue_number, owner, repo })
github.rest.issues.addLabels({ labels: labelsToAdd, issue_number, owner, repo })
labelsToRemove.forEach(labelToRemove => {
if (currentLabels.data.find(label => label.name === labelToRemove)) {
github.rest.issues.removeLabel({ name: labelToRemove, issue_number, owner, repo });
}
})
changes:
name: Changes requested
if: github.event.review.state == 'changes_requested'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
const issue_number = context.payload.pull_request.number
const owner = context.repo.owner
const repo = context.repo.repo
const labelsToAdd = ['changes-requested']
const labelsToRemove = ['approved']
const currentLabels = await github.rest.issues.listLabelsOnIssue({ issue_number, owner, repo })
github.rest.issues.addLabels({ labels: labelsToAdd, issue_number, owner, repo })
labelsToRemove.forEach(labelToRemove => {
if (currentLabels.data.find(label => label.name === labelToRemove)) {
github.rest.issues.removeLabel({ name: labelToRemove, issue_number, owner, repo });
}
})