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
This commit is contained in:
Jonathan Desrosiers 2022-06-05 19:43:50 +00:00
parent 50fab6f6b4
commit 60e80c1fd9

View File

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