@@ -16,21 +16,15 @@ jobs:
1616 const issue = context.payload.issue;
1717 const body = issue.body || "";
1818
19- // Normalize body for easier matching
20- const normalized = body
21- .toLowerCase()
22- .replace(/\s+/g, " ")
23- .trim();
24-
2519 // Check if the issue contains the template headers
2620 const hasTemplate =
27- normalized .includes("page url ") &&
28- normalized .includes("what 's wrong") &&
29- normalized .includes("suggested fix") &&
30- normalized .includes("additional context");
21+ body .includes("Page URL ") &&
22+ body .includes("What 's wrong") &&
23+ body .includes("Suggested fix") &&
24+ body .includes("Additional context");
3125
3226 if (!hasTemplate) {
33- // Issue doesn't use template at all - let it through
27+ // Issue doesn't use template at all - let it through with reminder
3428 await github.rest.issues.createComment({
3529 owner: context.repo.owner,
3630 repo: context.repo.repo,
@@ -50,53 +44,39 @@ jobs:
5044 return;
5145 }
5246
53- // Extract content after each header
54- const extractAfterHeader = (text, header) => {
55- const regex = new RegExp(`${header}\\s*(.+?)(?=###|$)`, 's');
56- const match = text.match(regex);
57- return match ? match[1].trim() : '';
58- };
59-
60- const pageUrlContent = extractAfterHeader(body, '### Page URL');
61- const whatsWrongContent = extractAfterHeader(body, "### What's wrong\\?");
62- const suggestedFixContent = extractAfterHeader(body, '### Suggested fix \\(optional\\)');
63- const additionalContextContent = extractAfterHeader(body, '### Additional context');
64-
65- // Check if any section has meaningful content (more than just whitespace/newlines)
66- const hasContent = (content) => {
67- return content.replace(/\s+/g, '').length > 0;
47+ // Function to remove HTML comments
48+ const removeComments = (text) => {
49+ return text.replace(/<!--[\s\S]*?-->/g, '');
6850 };
6951
70- const hasPageUrl = hasContent(pageUrlContent);
71- const hasWhatsWrong = hasContent(whatsWrongContent);
72- const hasSuggestedFix = hasContent(suggestedFixContent);
73- const hasAdditionalContext = hasContent(additionalContextContent);
52+ // Extract content after "What's wrong?" header
53+ const whatsWrongMatch = body.match(/What's wrong\?\s*\n+([\s\S]*?)(?=\n#{1,3}\s|$)/i);
54+ const whatsWrongContent = whatsWrongMatch ? removeComments(whatsWrongMatch[1]).trim() : '';
7455
75- // Consider it empty if none of the required sections have content
76- // (suggested fix is optional, so we don't require it)
77- const looksEmpty = !hasPageUrl && !hasWhatsWrong && !hasAdditionalContext;
56+ // Check if "What's wrong?" section is empty or only whitespace after removing comments
57+ const whatsWrongIsEmpty = !whatsWrongContent || whatsWrongContent.replace(/\s+/g, '').length === 0;
7858
79- if (looksEmpty ) {
59+ if (whatsWrongIsEmpty ) {
8060 await github.rest.issues.createComment({
8161 owner: context.repo.owner,
8262 repo: context.repo.repo,
8363 issue_number: issue.number,
84- body: `This issue doesn't follow our issue template and is missing critical information.
64+ body: `This issue is missing the most critical information: **what's wrong** .
8565
86- **What's missing:**
87- - Explanation of the problem
88- - Page or source details
89- - Additional context or supporting information
66+ Please describe the problem you're experiencing so we can help you effectively.
9067
91- This often happens when issues are created automatically or without being fully filled out.
68+ This issue will be closed, but feel free to reopen it once you've added:
69+ - A clear description of the problem
70+ - What you expected to happen
71+ - What actually happened
9272
93- Please feel free to reopen this issue once the required details are added. Thank you. 🙏`
73+ Thank you! 🙏`
9474 });
9575 await github.rest.issues.addLabels({
9676 owner: context.repo.owner,
9777 repo: context.repo.repo,
9878 issue_number: issue.number,
99- labels: ["invalid", "question "]
79+ labels: ["invalid", "needs-info "]
10080 });
10181 await github.rest.issues.update({
10282 owner: context.repo.owner,
10787 return;
10888 }
10989
110- // Issue has content - post welcome message
90+ // Issue has content in "What's wrong?" - post welcome message
11191 await github.rest.issues.createComment({
11292 owner: context.repo.owner,
11393 repo: context.repo.repo,
0 commit comments