-
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (58 loc) · 2.06 KB
/
pr-labeller.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
name: 'Pull Request Labeller'
on:
pull_request_target:
types:
- closed
- opened
- reopened
- synchronize
- converted_to_draft
- ready_for_review
- review_requested
- review_request_removed
jobs:
label:
runs-on: ubuntu-20.04
steps:
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.issue.number;
const pull = await github.rest.pulls.get({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
pull_number: context.issue.number
});
if (pull.data.state === "closed") {
if (pull.data.merged) {
await github.rest.issues.setLabels({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
issue_number: context.issue.number,
labels: ["✅ pull: accepted"]
})
}
else {
await github.rest.issues.setLabels({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
issue_number: context.issue.number,
labels: ["❌ pull: rejected"]
})
}
} else if (pull.data.draft) {
await github.rest.issues.setLabels({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
issue_number: context.issue.number,
labels: ["⚒️ pull: work in progress"]
})
} else {
await github.rest.issues.setLabels({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
issue_number: context.issue.number,
labels: ["🔍 pull: ready for review"]
})
}