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
|
name: Label issues from form
on:
issues:
types: [opened]
permissions:
issues: write
jobs:
label:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const body = context.payload.issue.body || "";
// Parse "### Title\n\nanswer" sections into a map
const sections = {};
body.split(/^### /m).slice(1).forEach((block) => {
const [title, ...rest] = block.split("\n");
sections[title.trim()] = rest.join("\n").trim();
});
const get = (k) => {
const v = sections[k];
return v && v !== "_No response_" ? v : null;
};
const gameLabels = {
"Mario Kart World": "Mario Kart",
"Donkey Kong Bananza": "DKB",
"Fire Emblem": "Fire Emblem",
"Splatoon Raiders": "Splatoon Raiders",
"Pokopia": "Pokopia",
"Hyrule Warriors": "Hyrule Warriors",
"Welcome Tour": "Welcome Tour",
};
const labels = new Set();
// Game
const game = get("Game");
if (game && gameLabels[game]) labels.add(gameLabels[game]);
// GPU vendor
const gpu = get("Graphics card");
if (gpu) {
if (/nvidia/i.test(gpu)) labels.add("NVIDIA");
else if (/amd/i.test(gpu)) labels.add("AMD");
else if (/intel/i.test(gpu)) labels.add("INTEL");
}
// OS
const os = get("Operating system");
if (os) {
if (/windows/i.test(os)) labels.add("windows");
else if (/linux/i.test(os)) labels.add("linux");
else if (/macos/i.test(os)) labels.add("MacOS");
}
// Regression
if (/- \[x\] This is a regression/i.test(sections["Regression"] || "")) {
labels.add("regression");
}
if (get("Last known working build")) labels.add("needs-bisect");
// Crash without log
const isCrash = (context.payload.issue.labels || []).some(
(l) => l.name.toLowerCase() === "crash"
);
if (isCrash && !get("Log / crash dump")) {
labels.add("needs-info");
await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: "Thanks for the report! Please attach the log / crash dump so we can investigate.",
});
}
if (labels.size) {
await github.rest.issues.addLabels({
...context.repo,
issue_number: context.issue.number,
labels: [...labels],
});
}
|