@@ -27,45 +27,105 @@ jobs:
2727 );
2828
2929 const characterCategoryLabels = [
30- "character:metadata",
31- "character:opening-animation",
32- "character:interaction-animation",
33- "character:animation-blend",
34- "character:subtitle",
35- "character:bgm",
36- "character:voice",
37- "character:vfx",
38- "character:other"
30+ "character:bug: metadata",
31+ "character:bug: opening-animation",
32+ "character:bug: interaction-animation",
33+ "character:bug: animation-blend",
34+ "character:bug: subtitle",
35+ "character:bug: bgm",
36+ "character:bug: voice",
37+ "character:bug: vfx",
38+ "character:bug: other"
3939 ];
4040
4141 const softwareCategoryLabels = [
42- "software:ui-interaction",
43- "software:ui-animation",
44- "software:logic",
45- "software:function",
46- "software:performance",
47- "software:other"
42+ "software:bug:ui-interaction",
43+ "software:bug:ui-animation",
44+ "software:bug:logic",
45+ "software:bug:function",
46+ "software:bug:performance",
47+ "software:bug:other",
48+ "software:bug:ui-interaction",
49+ "software:bug:ui-animation",
50+ "software:bug:logic",
51+ "software:bug:function",
52+ "software:bug:performance",
53+ "software:bug:other",
54+ "software:feat:logic-function",
55+ "software:feat:ui-function",
56+ "software:feat:logic-optimization",
57+ "software:feat:setting"
4858 ];
4959
5060 const characterMap = {
51- "元数据异常": "character:metadata",
52- "开场动画异常": "character:opening-animation",
53- "交互动画异常": "character:interaction-animation",
54- "动画混合异常": "character:animation-blend",
55- "字幕异常": "character:subtitle",
56- "背景音乐异常": "character:bgm",
57- "语音异常": "character:voice",
58- "视效异常": "character:vfx",
59- "其他": "character:other"
61+ "元数据异常": "character:bug: metadata",
62+ "开场动画异常": "character:bug: opening-animation",
63+ "交互动画异常": "character:bug: interaction-animation",
64+ "动画混合异常": "character:bug: animation-blend",
65+ "字幕异常": "character:bug: subtitle",
66+ "背景音乐异常": "character:bug: bgm",
67+ "语音异常": "character:bug: voice",
68+ "视效异常": "character:bug: vfx",
69+ "其他": "character:bug: other"
6070 };
6171
6272 const softwareMap = {
63- "UI 交互异常": "software:ui-interaction",
64- "UI 动画异常": "software:ui-animation",
65- "操作逻辑异常": "software:logic",
66- "功能异常": "software:function",
67- "性能异常": "software:performance",
68- "其他": "software:other"
73+ "UI 交互异常": "software:bug:ui-interaction",
74+ "UI 动画异常": "software:bug:ui-animation",
75+ "操作逻辑异常": "software:bug:logic",
76+ "功能异常": "software:bug:function",
77+ "性能异常": "software:bug:performance",
78+ "其他": "software:bug:other"
79+ };
80+
81+ const softwareFeatureMap = {
82+ "逻辑功能": "software:feat:logic-function",
83+ "UI 功能": "software:feat:ui-function",
84+ "逻辑优化": "software:feat:logic-optimization",
85+ "设置条目": "software:feat:setting"
86+ };
87+
88+ const labelMetadata = {
89+ "software:bug:ui-interaction": {
90+ color: "d73a4a",
91+ description: "软件缺陷:UI 交互异常。"
92+ },
93+ "software:bug:ui-animation": {
94+ color: "d73a4a",
95+ description: "软件缺陷:UI 动画异常。"
96+ },
97+ "software:bug:logic": {
98+ color: "d73a4a",
99+ description: "软件缺陷:操作逻辑异常。"
100+ },
101+ "software:bug:function": {
102+ color: "d73a4a",
103+ description: "软件缺陷:功能异常。"
104+ },
105+ "software:bug:performance": {
106+ color: "d73a4a",
107+ description: "软件缺陷:性能异常。"
108+ },
109+ "software:bug:other": {
110+ color: "d73a4a",
111+ description: "软件缺陷:其他软件异常。"
112+ },
113+ "software:feat:logic-function": {
114+ color: "a2eeef",
115+ description: "软件建议:逻辑功能。"
116+ },
117+ "software:feat:ui-function": {
118+ color: "a2eeef",
119+ description: "软件建议:UI 功能。"
120+ },
121+ "software:feat:logic-optimization": {
122+ color: "a2eeef",
123+ description: "软件建议:逻辑优化。"
124+ },
125+ "software:feat:setting": {
126+ color: "a2eeef",
127+ description: "软件建议:设置条目。"
128+ }
69129 };
70130
71131 function extractField(fieldName) {
99159 core.info(`Label already exists: ${labelName}`);
100160 return;
101161 }
162+ await ensureLabelExists(labelName);
102163 await github.rest.issues.addLabels({
103164 owner: context.repo.owner,
104165 repo: context.repo.repo,
@@ -108,11 +169,41 @@ jobs:
108169 core.info(`Added label: ${labelName}`);
109170 }
110171
172+ async function ensureLabelExists(labelName) {
173+ const metadata = labelMetadata[labelName];
174+ if (!metadata) return;
175+
176+ try {
177+ await github.rest.issues.getLabel({
178+ owner: context.repo.owner,
179+ repo: context.repo.repo,
180+ name: labelName
181+ });
182+ } catch (error) {
183+ if (error.status !== 404) {
184+ throw error;
185+ }
186+
187+ await github.rest.issues.createLabel({
188+ owner: context.repo.owner,
189+ repo: context.repo.repo,
190+ name: labelName,
191+ color: metadata.color,
192+ description: metadata.description
193+ });
194+ core.info(`Created label: ${labelName}`);
195+ }
196+ }
197+
111198 const issueType = extractField("问题类型");
112199 core.info(`Extracted 问题类型: ${issueType || "(empty)"}`);
113200
201+ const suggestionType = extractField("建议类型");
202+ core.info(`Extracted 建议类型: ${suggestionType || "(empty)"}`);
203+
114204 const isCharacter = currentLabels.includes("character");
115205 const isSoftware = currentLabels.includes("software");
206+ const isFeature = currentLabels.includes("enhancement");
116207
117208 if (!isCharacter && !isSoftware) {
118209 core.info('Skip: neither "character" nor "software" label found.');
@@ -125,6 +216,11 @@ jobs:
125216 }
126217
127218 if (isCharacter) {
219+ if (!issueType) {
220+ core.info('Skip: character issue form does not contain a bug category field.');
221+ return;
222+ }
223+
128224 const newLabel = characterMap[issueType];
129225 if (!newLabel) {
130226 core.warning(`No mapped character label for issue type: ${issueType}`);
@@ -142,9 +238,9 @@ jobs:
142238 }
143239
144240 if (isSoftware) {
145- const newLabel = softwareMap[issueType];
241+ const newLabel = isFeature ? softwareFeatureMap[suggestionType] : softwareMap[issueType];
146242 if (!newLabel) {
147- core.warning(`No mapped software label for issue type : ${issueType}`);
243+ core.warning(`No mapped software label for category : ${isFeature ? suggestionType : issueType}`);
148244 return;
149245 }
150246
0 commit comments