Skip to content

Notify on main Failure #11

Notify on main Failure

Notify on main Failure #11

Workflow file for this run

name: Notify on `main` Failure
on:
workflow_run:
workflows: [Failing Workflow]
types: [completed]
branches: [main]
jobs:
on-failure:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'timed_out'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Read Slack JSON file
id: read_json
run: |
# JSON_CONTENT=$(jq '.' .github/resources/slack_on_fail_block_kit.json)
JSON_CONTENT=$(cat .github/resources/slack_on_fail_block_kit.json)
echo "json_content<<EOF" >> $GITHUB_OUTPUT
echo "$JSON_CONTENT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# echo "json_content=$JSON_CONTENT" >> $GITHUB_OUTPUT
- run: |
echo "${{ steps.read_json.outputs.json_content }}"
- run: |
echo "${{ fromJson(steps.read_json.outputs.json_content) }}"
- uses: slackapi/slack-github-action@v1.24.0
with:
payload: ${{ fromJson(steps.read_json.outputs.json_content) }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.MOSHE_PERSONAL_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK