From 60e80c1fd9bfd49e04ecd57ddb5d27a833e2de46 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Sun, 5 Jun 2022 19:43:50 +0000 Subject: [PATCH] Build/Test Tools: Correctly confirm the previous workflow run was triggered by a push event. This fixes the code added in [53466] to look at the correct workflow object when determining the outcome of the previous workflow run. See #55652. git-svn-id: https://develop.svn.wordpress.org/trunk@53468 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/slack-notifications.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index 969d8b067e..1ae927ac0c 100644 --- a/.github/workflows/slack-notifications.yml +++ b/.github/workflows/slack-notifications.yml @@ -114,13 +114,18 @@ jobs: // Find the workflow run for the commit that immediately preceded this one. for ( let i = 0; i < previous_runs.data.workflow_runs.length; i++ ) { - // Protects against false notifications when contributors use similar head_ref names. - if ( previous_runs.data.workflow_runs[ i ].event !== "push" ) { - continue; - } - if ( previous_runs.data.workflow_runs[ i ].run_number == workflow_run.data.run_number ) { - return previous_runs.data.workflow_runs[ i + 1 ].conclusion; + let next_index = i; + do { + next_index++; + + // Protects against a false notification when contributors use the trunk branch as the pull request head_ref. + if ( previous_runs.data.workflow_runs[ next_index ].event !== "push" ) { + continue; + } + + return previous_runs.data.workflow_runs[ next_index ].conclusion; + } while ( next_index < previous_runs.data.workflow_runs.length ); } }