diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index 2d7674b3aa..dba50ade44 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