forked from MudBlazor/MudBlazor
-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (41 loc) · 1.66 KB
/
pr.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
on:
pull_request_target:
types: [opened]
jobs:
pr-bot:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
const pr = context.payload.pull_request;
const body = pr.body;
let labels = [];
const isChecked = /-\s*\[\s*[x|X]\s*\]\s*/;
if(RegExp(isChecked.source + "Bug fix \\(non-breaking change which fixes an issue\\)").test(body)) {
labels.push("bug");
console.log("PR type: bug fix.");
}
if(RegExp(isChecked.source + "New feature \\(non-breaking change which adds functionality\\)").test(body)) {
labels.push("enhancement");
console.log("PR type: enhancement.");
}
if(RegExp(isChecked.source + "Breaking change \\(fix or feature that would cause existing functionality to not work as expected\\)").test(body)) {
labels.push("breaking change");
console.log("PR type: breaking change.");
}
if(RegExp(isChecked.source + "Documentation \\(fix or improvement to the website or code docs\\)").test(body)) {
labels.push("docs");
console.log("PR type: documentation.");
}
if(!pr.draft) {
labels.push("PR: needs review");
}
if(labels.length != 0) {
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
})
}