Skip to content

Commit 9c200e6

Browse files
Improve name extraction (#1982)
Signed-off-by: Riaan Kleinhans <[email protected]>
1 parent cd1cb26 commit 9c200e6

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

.github/workflows/create-tech-review.yml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,19 @@ jobs:
1818
with:
1919
github-token: ${{ secrets.GITHUB_TOKEN }}
2020
script: |
21-
(async () => {
2221
// --- Constants ---
2322
const FIELD_LABELS = {
2423
name: [
2524
'Project name', 'Name', 'name', 'project name', 'project-name', 'subproject-name', 'Project Name', 'Subproject Name'
2625
],
2726
projectLink: [
28-
'Project link', 'project-link', 'project link', 'github-url', 'GitHub URL', 'Project link'
27+
'Project Repo(s)', 'Project Repo', 'Project link', 'project-link', 'project link', 'github-url', 'GitHub URL', 'Project link', 'Project Site'
2928
],
3029
ddLink: [
3130
'Due diligence link', 'dd-link', 'due diligence link', 'Due diligence', 'Due diligence link'
3231
],
3332
projectContact: [
34-
'Project contact', 'project-contact', 'project contact', 'Project contact information', 'Project Security Contacts', 'Project contact information'
33+
'Project points of contacts', 'Project points of contact', 'Project contact', 'project-contact', 'project contact', 'Project contact information', 'Project Security Contacts', 'Communication'
3534
],
3635
additionalInfo: [
3736
'Additional information', 'additional-information', 'additional information', 'Additional Information', 'Additional information'
@@ -82,17 +81,38 @@ jobs:
8281
function extractFormField(body, fieldKey) {
8382
if (!body) return null;
8483
const labels = FIELD_LABELS[fieldKey] || [fieldKey];
84+
85+
// First try GitHub template format: ### Field Label\n\nvalue
8586
for (const label of labels) {
8687
const escapedLabel = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
87-
const pattern = new RegExp(
88+
const templatePattern = new RegExp(
8889
`###\\s+${escapedLabel}[^\\n]*\\n\\n([\\s\\S]*?)(?=\\n###|$)`,
8990
'i'
9091
);
91-
const match = body.match(pattern);
92-
if (match && match[1] && match[1].trim().length > 0) {
93-
return match[1].trim();
92+
const templateMatch = body.match(templatePattern);
93+
if (templateMatch && templateMatch[1] && templateMatch[1].trim().length > 0) {
94+
return templateMatch[1].trim();
9495
}
9596
}
97+
98+
// Fallback: Try plain text format: Field Label: value
99+
for (const label of labels) {
100+
const escapedLabel = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
101+
// Match "Field Label:" or "Field Label" followed by colon and value
102+
const plainPattern = new RegExp(
103+
`^${escapedLabel}\\s*:?\\s+(.+)$`,
104+
'im'
105+
);
106+
const plainMatch = body.match(plainPattern);
107+
if (plainMatch && plainMatch[1] && plainMatch[1].trim().length > 0) {
108+
// Extract value, stopping at newline or end
109+
const value = plainMatch[1].trim().split(/\n/)[0].trim();
110+
if (value.length > 0) {
111+
return value;
112+
}
113+
}
114+
}
115+
96116
return null;
97117
}
98118
@@ -211,5 +231,4 @@ jobs:
211231
await commentOnce(issueNumber, COMMENT_MARKERS.createTechReviewFailed,
212232
`❌ Failed to create tech review issue: ${error.message}`);
213233
throw error;
214-
}
215-
})();
234+
}

0 commit comments

Comments
 (0)