Skip to content

[P1][Tier 5] Adopt a correct-once loop with a lightweight AI-artifact update intake #1164

[P1][Tier 5] Adopt a correct-once loop with a lightweight AI-artifact update intake

[P1][Tier 5] Adopt a correct-once loop with a lightweight AI-artifact update intake #1164

name: Validation Status Comment Label Handler
on:
issue_comment:
types:
- created
- edited
permissions:
issues: write
contents: read
jobs:
add_status_label:
if: github.event.issue.pull_request == null
runs-on: ubuntu-latest
steps:
- name: Add validationstatus label based on comment text
uses: actions/github-script@v7
with:
script: |
const body = context.payload.comment?.body ?? '';
const normalized = body.trim().toLowerCase();
let labelToAdd = null;
if (/^status\s*:\s*fixed$/.test(normalized)) {
labelToAdd = 'fixed';
} else if (/^status\s*:\s*not\s+fixed$/.test(normalized)) {
labelToAdd = 'not-fixed';
}
if (!labelToAdd) {
console.log(`Comment did not match a status command: "${body}"`);
return;
}
const labelToRemove = labelToAdd === 'fixed' ? 'not-fixed' : 'fixed';
const issueNumber = context.payload.issue.number;
// Remove the opposing label if present
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
...context.repo,
issue_number: issueNumber,
});
if (currentLabels.some(l => l.name === labelToRemove)) {
await github.rest.issues.removeLabel({
...context.repo,
issue_number: issueNumber,
name: labelToRemove,
});
console.log(`Removed label "${labelToRemove}" from issue #${issueNumber}`);
}
await github.rest.issues.addLabels({
...context.repo,
issue_number: issueNumber,
labels: [labelToAdd],
});
console.log(`Added label "${labelToAdd}" to issue #${issueNumber}`);