Skip to content

Commit 815efd2

Browse files
committed
Fix orchestrator anomalies: ignore skipped/cancelled runs, and match tasks by run name issue ID
1 parent 7f66e59 commit 815efd2

2 files changed

Lines changed: 28 additions & 12 deletions

File tree

.github/scripts/orchestrator.js

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,25 +194,40 @@ module.exports = async ({ github, context, core }) => {
194194
return;
195195
}
196196

197+
// Fetch conclusion
198+
const conclusion = context.payload.workflow_run.conclusion;
199+
200+
// 1. Ignore non-definitive skipped or cancelled runs
201+
if (conclusion === 'skipped' || conclusion === 'cancelled') {
202+
core.info(`Workflow run completed with conclusion "${conclusion}". Ignoring.`);
203+
return;
204+
}
205+
197206
// Fetch the display title of the completed workflow run
198-
const runTitle = context.payload.workflow_run.display_title;
207+
const runTitle = context.payload.workflow_run.display_title || '';
199208

200-
// Fetch current task issue details to get the title
209+
// Extract issue number from display title (e.g. "Review #415: Review Thinlet.java")
210+
const match = runTitle.match(/Review #(\d+)/);
211+
if (!match) {
212+
core.info(`Workflow run display title "${runTitle}" does not contain expected "Review #[number]" format. Skipping.`);
213+
return;
214+
}
215+
216+
const runIssueNumber = parseInt(match[1], 10);
217+
core.info(`Extracted completed Task #${runIssueNumber} from workflow run title: "${runTitle}"`);
218+
219+
// Issue ID mismatch protection (strict sequential validation guard)
220+
if (runIssueNumber !== state.current_task) {
221+
core.info(`Workflow run for Task #${runIssueNumber} does not match current active task #${state.current_task}. Waiting for current task.`);
222+
return;
223+
}
224+
225+
// Fetch current task issue details
201226
const currentIssue = await github.rest.issues.get({
202227
owner: context.repo.owner,
203228
repo: context.repo.repo,
204229
issue_number: state.current_task
205230
});
206-
const issueTitle = currentIssue.data.title;
207-
208-
// Title mismatch protection (strict sequential validation guard)
209-
if (runTitle !== issueTitle) {
210-
core.info(`Workflow run display title "${runTitle}" does not match current task title "${issueTitle}". Waiting for current task.`);
211-
return;
212-
}
213-
214-
// Check success conditions (workflow conclusion = success, and issue is CLOSED)
215-
const conclusion = context.payload.workflow_run.conclusion;
216231
const isIssueClosed = currentIssue.data.state === 'closed';
217232

218233
if (conclusion === 'success' && isIssueClosed) {

.github/workflows/opencode.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: opencode
2+
run-name: "Review #${{ github.event.issue.number }}: ${{ github.event.issue.title }}"
23

34
on:
45
issue_comment:

0 commit comments

Comments
 (0)