From d3f193f741742cfb0fde99f3eb9bd5acbd216d21 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Thu, 17 Aug 2023 16:59:49 +0000 Subject: [PATCH] =?UTF-8?q?Build/Test=20Tools:=20Don=E2=80=99t=20send=20a?= =?UTF-8?q?=20Slack=20notice=20when=20a=20workflow=20fails=20once.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [53947] introduced a callable workflow that allowed a workflow run to be retried automatic. By default all workflows are retried once. Since a run is not considered “failed” until after the automatic retry, the first Slack message is unnecessary and can cause a lot of noise when there are network hiccups. This alters the logic to skip a failure notice in Slack until the second failure. See #58867. git-svn-id: https://develop.svn.wordpress.org/trunk@56404 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/slack-notifications.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index 2d7674b3aabc8..dba50ade44d31 100644 --- a/.github/workflows/slack-notifications.yml +++ b/.github/workflows/slack-notifications.yml @@ -71,6 +71,11 @@ jobs: run_id: ${{ github.run_id }}, }); + // All workflows will restart once when a failure is encountered. Don't notify Slack on the first failure. + if ( '${{ inputs.calling_status }}' == 'failure' && workflow_run.data.run_attempt == 1 ) { + return 'first-failure'; + } + // When a workflow has been restarted to fix a failure, check the previous run attempt. if ( workflow_run.data.run_attempt > 1 ) { const previous_run = await github.rest.actions.getWorkflowRunAttempt({ @@ -157,7 +162,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 needs: [ prepare ] - if: ${{ inputs.calling_status == 'failure' || failure() }} + if: ${{ ( inputs.calling_status == 'failure' || failure() ) && steps.previous-attempt-result.outputs.result != 'first-failure' }} steps: - name: Post failure notifications to Slack