Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

Commit c269e2d

Browse files
authored
Merge pull request #8 from calebephrem/main
fix: prevent empty labels when auto-labeling issues
2 parents b1bc0b6 + 8864048 commit c269e2d

1 file changed

Lines changed: 26 additions & 30 deletions

File tree

β€Ž.github/workflows/bot.ymlβ€Ž

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
Β (0)