diff --git a/.github/workflows/notify_slack.yml b/.github/workflows/notify_slack.yml new file mode 100644 index 000000000..dda88a988 --- /dev/null +++ b/.github/workflows/notify_slack.yml @@ -0,0 +1,39 @@ +name: Notify Slack +on: + workflow_call: + inputs: + result: + type: string + required: true + run_id: + type: string + required: false + workflow_name: + type: string + required: true + +jobs: + notify: + name: Notify Slack Failure + runs-on: ubuntu-latest + if: ${{ inputs.result == 'failure' }} + steps: + - name: Slack Notification + uses: tokorom/action-slack-incoming-webhook@main + env: + INCOMING_WEBHOOK_URL: ${{ secrets.DEPLOY_SLACK_WEBHOOK_URL }} + with: + text: Scheduled Run Failed - ${{ inputs.workflow_name }} + attachments: | + [ + { + "color": "danger", + "fields": + [ + { + "title": "URL:", + "value": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ inputs.run_id }}" + } + ] + } + ] diff --git a/.github/workflows/test-all-warehouses.yml b/.github/workflows/test-all-warehouses.yml index 1c12de582..9efdd7833 100644 --- a/.github/workflows/test-all-warehouses.yml +++ b/.github/workflows/test-all-warehouses.yml @@ -45,3 +45,17 @@ jobs: dbt-version: ${{ matrix.dbt-version }} generate-data: ${{ inputs.generate-data || false }} secrets: inherit + + notify_failures: + name: Notify Slack + needs: test + if: | + always() && + contains(needs.test.result, 'failure') && + # ! cancelled() && + ${{ github.event_name == 'schedule' }} + uses: ./.github/workflows/notify_slack.yml + with: + result: "failure" + run_id: ${{ github.run_id }} + workflow_name: "Test all warehouse platforms" diff --git a/.github/workflows/test-github-action.yml b/.github/workflows/test-github-action.yml index eff4a623a..358b39900 100644 --- a/.github/workflows/test-github-action.yml +++ b/.github/workflows/test-github-action.yml @@ -101,3 +101,17 @@ jobs: with: name: edr.log path: edr_target/edr.log + + notify_failures: + name: Notify Slack + needs: test + if: | + always() && + contains(needs.test.result, 'failure') && + ! cancelled() && + ${{ github.event_name == 'schedule' }} + uses: ./.github/workflows/notify_slack.yml + with: + result: "failure" + run_id: ${{ github.run_id }} + workflow_name: "Test Elementary GitHub action"