@@ -176,58 +176,54 @@ jobs:
176176
177177 const text = `${issue.title}\n${issue.body || ""}`.toLowerCase();
178178
179- const labels = new Set() ;
179+ const detectedLabels = [] ;
180180
181181 const rules = [
182- {
183- keywords: ["bug", "error", "crash", "fail"],
184- label: "bug",
185- },
186- {
187- keywords: ["feature", "request", "enhancement"],
188- label: "enhancement",
189- },
190- {
191- keywords: ["doc", "docs", "readme"],
192- label: "docs",
193- },
194- {
195- keywords: ["question", "help"],
196- label: "question",
197- },
182+ { keywords: ["bug", "error", "crash", "fail"], label: "bug" },
183+ { keywords: ["feature", "request", "enhancement"], label: "enhancement" },
184+ { keywords: ["doc", "docs", "readme"], label: "documentation" },
185+ { keywords: ["question", "help"], label: "question" },
198186 ];
199187
200188 for (const rule of rules) {
201- if (rule.keywords.some((k) => text.includes(k))) {
202- labels.add(rule.label);
189+ if (
190+ rule.label &&
191+ rule.keywords.some((k) => text.includes(k))
192+ ) {
193+ detectedLabels.push(rule.label);
203194 }
204195 }
205196
206- if (labels.size > 0) {
197+ // Deduplicate + remove invalid values
198+ const labels = [...new Set(detectedLabels)].filter(
199+ (l) => typeof l === "string" && l.trim().length > 0
200+ );
201+
202+ if (labels.length > 0) {
207203 await github.rest.issues.addLabels({
208204 owner: context.repo.owner,
209205 repo: context.repo.repo,
210206 issue_number: issue.number,
211- labels: Array.from(labels) ,
207+ labels,
212208 });
213209 }
214210
215- const commentLines = [
211+ const comment = [
216212 "π **Thanks for opening this issue!**",
217213 "",
218- "The Open DevHub maintainers have been notified and will review it as soon as possible π",
214+ "The DevHub maintainers have been notified and will review it ASAP π",
219215 "",
220- "π **Tips to speed things up :**",
221- "- Provide clear steps to reproduce (if it's a bug )",
222- "- Attach screenshots or logs if relevant ",
223- "- Mention expected vs actual behavior ",
216+ "π **Tips to help us help you :**",
217+ "- Clear steps to reproduce (for bugs )",
218+ "- Expected vs actual behavior ",
219+ "- Screenshots or logs if applicable ",
224220 "",
225- "We appreciate your contribution π",
226- ];
221+ "Thanks for contributing π",
222+ ].join("\n") ;
227223
228224 await github.rest.issues.createComment({
229225 owner: context.repo.owner,
230226 repo: context.repo.repo,
231227 issue_number: issue.number,
232- body: commentLines.join("\n") ,
228+ body: comment ,
233229 });
0 commit comments