Skip to content

Commit

Permalink
Build/Test Tools: Don’t send a Slack notice when a workflow fails once.
Browse files Browse the repository at this point in the history
[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
  • Loading branch information
desrosj committed Aug 17, 2023
1 parent 2bd2a2f commit d3f193f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .github/workflows/slack-notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d3f193f

Please sign in to comment.