-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (43 loc) · 2.08 KB
/
on-fail.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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