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 ); } }