Build/Test Tools: Prevent error when workflows run for new branches and tags.

This fixes a JavaScript error in the Slack notifications workflow. This was causing the first workflow run for each workflow in a new branch or tag to be reported as a failure, even if the important parts of the workflow succeed.

When running a workflow for the first time, a default of `failure` is now used for the previous outcome. This will trigger a success notification to be sent to report successful branching/tagging.

Props davidbaumwald.
Fixes #54742.

git-svn-id: https://develop.svn.wordpress.org/trunk@53077 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers
2022-04-05 13:18:53 +00:00
parent 3a9abc810a
commit 10b258f61c

View File

@@ -94,7 +94,13 @@ jobs:
per_page: 1,
page: 2,
});
return previous_runs.data.workflow_runs[0].conclusion;
if ( previous_runs.data.total_count > 0 ) {
return previous_runs.data.workflow_runs[0].conclusion;
} else {
// Use failure so all first time runs for a branch or tag are reported to Slack.
return 'failure';
}
- name: Store previous conclusion as an output
id: previous-conclusion