Skip to content

Notify on main Failure #26

Notify on main Failure

Notify on main Failure #26

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: |
echo "Skipping..."
# JSON_CONTENT=$(jq '.' .github/resources/slack_on_fail_block_kit.json --compact-output)
# # 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) }}"
- name: Replace Slack JSON File Variables
run: |
TRIGGERING_WORKFLOW_RUN_URL="${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}"
DETAILS_LINK="<${{github.server_url}}/${{github.repository}}|${{github.repository}}> | <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}|View Failure>"
echo $TRIGGERING_WORKFLOW_RUN_URL
echo $DETAILS_LINK
sed -i 's;$runURL;'"$TRIGGERING_WORKFLOW_RUN_URL"';g' .github/resources/slack_on_fail_block_kit.json
sed -i 's;$viewFailure;'"$DETAILS_LINK"';g' .github/resources/slack_on_fail_block_kit.json
cat .github/resources/slack_on_fail_block_kit.json
- uses: slackapi/slack-github-action@v1.24.0
with:
# payload: ${{ fromJson(steps.read_json.outputs.json_content) }}
payload-file-path: .github/resources/slack_on_fail_block_kit.json
env:
SLACK_WEBHOOK_URL: ${{ secrets.MOSHE_PERSONAL_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK