-
Notifications
You must be signed in to change notification settings - Fork 2.1k
81 lines (70 loc) · 2.44 KB
/
issue_opened.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
name: Label issues
on:
issues:
types:
- reopened
- opened
env:
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_TITLE: ${{ github.event.issue.title }}
jobs:
label_issues:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/github-script@v6
with:
script: |
const issue = {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
};
// Is the title long enough to convey any useful meaning?
if (process.env.ISSUE_TITLE.length < 10)
{
github.rest.issues.createComment({
...issue,
body: "Closing this issue, the title is too short to convey any real meaning, please create another issue with an explanatory title."
});
github.rest.issues.update({
...issue,
state: "closed",
state_reason: "not_planned"
});
return;
}
// labels
{
var addLabels = ["triage"];
const issueBody = process.env.ISSUE_BODY;
const areasStringRegex = /### Area\(s\)\s*(.*)/;
const areasLabels = [ "FxDK", "RedM", "ScRT: Lua", "ScRT: C#", "ScRT: JS" ];
var areasString = areasStringRegex.exec(issueBody);
if (areasString && areasString.length > 1)
{
var areas = areasString[1].split(/\s*[,\n]\s*/);
for (var i = 0; i < areas.length; ++i)
{
const area = areas[i];
if (areasLabels.includes(area))
{
addLabels.push(area);
}
}
}
const priorityStringRegex = /### Importancy\s*(.*)/;
var priorityString = priorityStringRegex.exec(issueBody);
if (priorityString)
{
switch (priorityString[1])
{
case "Crash": addLabels.push("crash"); break;
}
}
github.rest.issues.addLabels({
...issue,
labels: addLabels
});
}