Skip to content

Commit

Permalink
Move to file based message (block kit)
Browse files Browse the repository at this point in the history
  • Loading branch information
moshe-azaria-sage committed Mar 18, 2024
1 parent de84f8b commit dc9e68a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 41 deletions.
40 changes: 40 additions & 0 deletions .github/resources/slack_on_fail_block_kit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":warning: `main` branch failure in CI ",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "View run details: "
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Run Details",
"emoji": true
},
"value": "clicked_1",
"url": "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}",
"action_id": "button-action"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Linked Repo <${{github.server_url}}/${{github.repository}}|${{github.repository}}> | <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}|View Failure>",
"emoji": true
}
]
}
]
}
48 changes: 7 additions & 41 deletions .github/workflows/on-fail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,15 @@ jobs:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'timed_out'
steps:
- name: Read Slack JSON file
id: read_json
run: |
JSON_CONTENT=$(jq '.' .github/resources/slack_on_fail_block_kit.json)
echo "json_content=$JSON_CONTENT" >> $GITHUB_OUTPUT
- uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":warning: `main` branch failure in CI ",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "View run details: "
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Run Details",
"emoji": true
},
"value": "clicked_1",
"url": "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}",
"action_id": "button-action"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Linked Repo <${{github.server_url}}/${{github.repository}}|${{github.repository}}> | <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}|View Failure>",
"emoji": true
}
]
}
]
}
payload: ${{ steps.read_json.outputs.json_content }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.MOSHE_PERSONAL_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

0 comments on commit dc9e68a

Please sign in to comment.