From 10b258f61c6efcb3421f9ff62c7f65a26f592131 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Tue, 5 Apr 2022 13:18:53 +0000 Subject: [PATCH] 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 --- .github/workflows/slack-notifications.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index 7a58813648..1e500dd394 100644 --- a/.github/workflows/slack-notifications.yml +++ b/.github/workflows/slack-notifications.yml @@ -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