chore(labels): switch slug label prefix to code/<slug>; prefer code/ with id/ fallback across workflows

This commit is contained in:
James Peter
2025-09-10 12:22:29 +10:00
parent 956d81dd08
commit dff6002224
4 changed files with 16 additions and 9 deletions
+5 -3
View File
@@ -74,11 +74,13 @@ jobs:
let slug = (context.eventName === 'repository_dispatch' && context.payload.client_payload && context.payload.client_payload.slug) ? String(context.payload.client_payload.slug).toLowerCase() : '';
const markerRe = /<!--\s*codex-id:\s*([a-z0-9-]{3,})\s*-->/i;
if (!slug) {
// Try issue label id/<slug>
// Try issue label code/<slug> (fallback id/<slug>)
try {
const { data: issue } = await github.rest.issues.get({ owner, repo, issue_number });
const idLabel = (issue.labels || []).map(l => (typeof l === 'string' ? l : l.name)).find(n => typeof n === 'string' && n.startsWith('id/'));
if (idLabel) slug = idLabel.slice(3).toLowerCase();
const labels = (issue.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) {
+4 -2
View File
@@ -145,8 +145,10 @@ jobs:
if (issue_number) {
try {
const { data: iss } = await github.rest.issues.get({ owner, repo, issue_number });
const idLabel = (iss.labels || []).map(l => (typeof l === 'string' ? l : l.name)).find(n => typeof n === 'string' && n.startsWith('id/'));
if (idLabel) slug = idLabel.slice(3).toLowerCase();
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 });
+3 -2
View File
@@ -460,6 +460,7 @@ jobs:
gate_reason=$(printf "Rate: %s\nSafety: %s" "${reason_rate:-none}" "${reason_safety:-none}")
printf '%s\n\n%s\n' \
"Thanks @${ACTOR}! This issue was auto-reviewed." \
"" \
"For safety, the bot did not auto-apply changes." \
"${gate_reason}" \
> .github/auto/ISSUE_COMMENT.md
@@ -510,14 +511,14 @@ jobs:
env:
SUGGESTED_ID: ${{ steps.safety.outputs.suggested_id }}
- name: Apply id/<slug> label and remove ID marker comments
- name: Apply code/<slug> label and remove ID marker comments
uses: actions/github-script@v7
with:
script: |
const owner = context.repo.owner; const repo = context.repo.repo; const issue_number = Number(process.env.ISSUE_NUMBER);
const slug = `${{ steps.slug.outputs.slug }}`;
if (slug) {
try { await github.rest.issues.addLabels({ owner, repo, issue_number, labels: [`id/${slug}`] }); } catch {}
try { await github.rest.issues.addLabels({ owner, repo, issue_number, labels: [`code/${slug}`] }); } catch {}
}
// Remove any previous codex-id marker comments to keep issues tidy
try {
+4 -2
View File
@@ -282,8 +282,10 @@ jobs:
if (issue_number) {
try {
const { data: iss } = await github.rest.issues.get({ owner, repo, issue_number });
const idLabel = (iss.labels || []).map(l => (typeof l === 'string' ? l : l.name)).find(n => typeof n === 'string' && n.startsWith('id/'));
if (idLabel) slug = idLabel.slice(3).toLowerCase();
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 });