@@ -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 ( / R e v i e w # ( \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 ) {
0 commit comments