Skip to content

Commit

Permalink
CI: send slack notification on failed nightly job (#18578)
Browse files Browse the repository at this point in the history
  • Loading branch information
huikang authored Aug 25, 2023
1 parent 051f250 commit c8ef063
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
5 changes: 2 additions & 3 deletions .github/scripts/notify_slack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1


set -uo pipefail

# This script is used in GitHub Actions pipelines to notify Slack of a job failure.
Expand All @@ -13,8 +12,8 @@ if [[ $GITHUB_REF_NAME == "main" ]]; then
COMMIT_MESSAGE=$(git log -1 --pretty=%B | head -n1)
SHORT_REF=$(git rev-parse --short "${GITHUB_SHA}")
curl -X POST -H 'Content-type: application/json' \
--data \
"{ \
--data \
"{ \
\"attachments\": [ \
{ \
\"fallback\": \"GitHub Actions workflow failed!\", \
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/nightly-test-integrations-1.15.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,14 @@ jobs:
printf "Tests failed or workflow cancelled:\n\n${{ toJSON(needs) }}"
exit 1
fi
- name: Notify Slack
if: ${{ failure() }}
id: slack
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
with:
payload: |
{
"message": "One or more nightly integration tests have failed on branch ${{ env.BRANCH }} for Consul. ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.CONSUL_NIGHTLY_INTEG_TEST_SLACK_WEBHOOK }}
11 changes: 11 additions & 0 deletions .github/workflows/nightly-test-integrations-1.16.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,14 @@ jobs:
printf "Tests failed or workflow cancelled:\n\n${{ toJSON(needs) }}"
exit 1
fi
- name: Notify Slack
if: ${{ failure() }}
id: slack
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
with:
payload: |
{
"message": "One or more nightly integration tests have failed on branch ${{ env.BRANCH }} for Consul. ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.CONSUL_NIGHTLY_INTEG_TEST_SLACK_WEBHOOK }}
11 changes: 11 additions & 0 deletions .github/workflows/nightly-test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,14 @@ jobs:
printf "Tests failed or workflow cancelled:\n\n${{ toJSON(needs) }}"
exit 1
fi
- name: Notify Slack
if: ${{ failure() }}
id: slack
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
with:
payload: |
{
"message": "One or more nightly integration tests have failed. ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.CONSUL_NIGHTLY_INTEG_TEST_SLACK_WEBHOOK }}

0 comments on commit c8ef063

Please sign in to comment.