fix(preview-build): resolve slug from code/<slug> label (fallback id/<slug> and marker) in release stage

This commit is contained in:
James Peter
2025-09-10 12:49:56 +10:00
parent dff6002224
commit 722af737f2
+11 -2
View File
@@ -201,8 +201,17 @@ jobs:
const b = pull.head.ref || '';
const im = b.match(/^issue-(\d+)$/); let issue_number = 0; if (im) issue_number = Number(im[1]);
if (issue_number) {
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number, per_page: 100 });
for (const c of comments) { const mm = (c.body || '').match(marker); if (mm) { slug = mm[1].toLowerCase(); break; } }
try {
const { data: iss } = await github.rest.issues.get({ owner, repo, issue_number });
const labels = (iss.labels || []).map(l => (typeof l === 'string' ? l : l.name)).filter(Boolean);
const codeLabel = labels.find(n => typeof n === 'string' && n.startsWith('code/'));
const idLabel = labels.find(n => typeof n === 'string' && n.startsWith('id/'));
if (codeLabel) slug = codeLabel.slice(5).toLowerCase(); else if (idLabel) slug = idLabel.slice(3).toLowerCase();
} catch {}
if (!slug) {
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number, per_page: 100 });
for (const c of comments) { const mm = (c.body || '').match(marker); if (mm) { slug = mm[1].toLowerCase(); break; } }
}
}
if (!slug) throw new Error('Missing codex-id marker on PR/issue.');
}