-
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (115 loc) · 4.32 KB
/
labeler.yaml
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Labeler
on:
push:
branches:
- main
issues:
types: [opened]
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
- unlabeled
branches:
- main
jobs:
label-sync:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Run Labeler
uses: crazy-max/ghaction-github-labeler@v4.0.0
with:
yaml-file: .github/labels.yaml
skip-delete: false
dry-run: false
version-label-check:
if: |
github.event_name == 'pull_request' &&
github.actor != 'dependabot[bot]' &&
(
contains( github.event.labels.*.name, 'BUMP_MAJOR' ) ||
contains( github.event.pull_request.labels.*.name, 'BUMP_MINOR' ) ||
contains( github.event.pull_request.labels.*.name, 'BUMP_PATCH' ) ||
join(github.event.issue.labels) == '' ||
(
!contains( github.event.labels.*.name, 'BUMP_MAJOR' ) &&
!contains( github.event.pull_request.labels.*.name, 'BUMP_MINOR' ) &&
!contains( github.event.pull_request.labels.*.name, 'BUMP_PATCH')
)
)
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}
steps:
- uses: actions/github-script@v6
id: script
with:
script: |
var total_labels = 0
const labels = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
console.log(labels.data)
for (const label of labels.data) {
if (label.name === 'BUMP_PATCH') {
total_labels += 1
var version = 'patch'
} else if (label.name === 'BUMP_MINOR') {
total_labels += 1
var version = 'minor'
} else if (label.name === 'BUMP_MAJOR') {
total_labels += 1
var version = 'major'
}
}
console.log(total_labels)
if (total_labels != 1) {
var status = 'error'
} else {
var status = 'success'
}
console.log(status)
core.setOutput('status', status)
console.log(version)
core.setOutput('version', version)
- uses: marocchino/sticky-pull-request-comment@v2
if: steps.script.outputs.status != 'success'
with:
header: improper-version-labels
message: |
# Improper Version Labels
You don't have the proper labels on this Pull Request to increment the version.
You must provide one and only one of the following labels to increment the version number:
- `BUMP_MAJOR`
- `BUMP_MINOR`
- `BUMP_PATCH`
delete: true
- uses: marocchino/sticky-pull-request-comment@v2
if: steps.script.outputs.status == 'success'
with:
header: improper-version-labels
delete: true
- if: steps.script.outputs.status != 'success'
run: |
echo "Incompatible Version Bump Labels Applied"
exit 1
apply-triage-label:
if: github.event_name == 'issues'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['triage']
})