Skip to content

Commit

Permalink
custom slack notification message 2/2 (#1792)
Browse files Browse the repository at this point in the history
Co-authored-by: Szymon Sadkowski <[email protected]>
  • Loading branch information
szysad and Szymon Sadkowski authored May 27, 2024
1 parent 0474e59 commit 16af9d9
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 18 deletions.
70 changes: 70 additions & 0 deletions .github/actions/job-notify-v2/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
name: Notify about job status
description: Send Slack channel notification about job finish status
inputs:
slack-webhook:
description: "A Slack Webhook to post a notification"
required: true
job-status:
description: "Finish status of a preceding job"
required: true


runs:
using: "composite"
steps:
- uses: 8398a7/action-slack@v3
env:
SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook }}
with:
status: custom
fields: job,repo,ref,author,took,message,eventName
custom_payload: |
{
blocks: [
{
type: 'section',
text: {
type: 'mrkdwn',
text: '${{ inputs.job-status }}' === 'success' ? ':sunglasses::100::fire: Github Workflow Finished With Success' : ':dizzy_face::clown_face::fire: Github Workflow Failed',
}
},
{
type: 'section',
fields: [
{
type: 'mrkdwn',
text: `*Author:*\n${process.env.AS_AUTHOR}`,
},
{
type: 'mrkdwn',
text: '*Environment:*\n' + (process.env.AS_REF === 'refs/heads/master' ? 'Production 1.x' : (process.env.AS_REF === 'refs/heads/dev/1.x' ? 'Production' : 'Unknown')),
},
{
type: 'mrkdwn',
text: `*Repo:*\n${process.env.AS_REPO}`,
},
{
type: 'mrkdwn',
text: `*Ref:*\n${process.env.AS_REF}`,
},
{
type: 'mrkdwn',
text: `*Message:*\n${process.env.AS_MESSAGE}`,
},
{
type: 'mrkdwn',
text: `*Job:*\n${process.env.AS_JOB}`,
},
{
type: 'mrkdwn',
text: `*Event:*\n${process.env.AS_EVENT_NAME}`,
},
{
type: 'mrkdwn',
text: `*Took:*\n${process.env.AS_TOOK}`,
},
]
}
]
}
67 changes: 67 additions & 0 deletions .github/actions/workflow-notify-v2/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: Notify about workflow status
description: Send Slack channel notification about workflow finish status
inputs:
slack-webhook:
description: "A Slack Webhook to post a notification"
required: true

runs:
using: "composite"
steps:
- uses: technote-space/workflow-conclusion-action@v3
- uses: 8398a7/action-slack@v3
env:
SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook }}
with:
status: custom
fields: job,repo,ref,author,took,message,eventName
custom_payload: |
{
blocks: [
{
type: 'section',
text: {
type: 'mrkdwn',
text: '${{ job.status }}' === 'success' ? ':sunglasses::100::fire: Github Workflow Finished With Success' : ':dizzy_face::clown_face::fire: Github Workflow Failed',
}
},
{
type: 'section',
fields: [
{
type: 'mrkdwn',
text: `*Author:*\n${process.env.AS_AUTHOR}`,
},
{
type: 'mrkdwn',
text: '*Environment:*\n' + (process.env.AS_REF === 'refs/heads/master' ? 'Production 1.x' : (process.env.AS_REF === 'refs/heads/dev/1.x' ? 'Production' : 'Unknown')),
},
{
type: 'mrkdwn',
text: `*Repo:*\n${process.env.AS_REPO}`,
},
{
type: 'mrkdwn',
text: `*Ref:*\n${process.env.AS_REF}`,
},
{
type: 'mrkdwn',
text: `*Message:*\n${process.env.AS_MESSAGE}`,
},
{
type: 'mrkdwn',
text: `*Job:*\n${process.env.AS_JOB}`,
},
{
type: 'mrkdwn',
text: `*Event:*\n${process.env.AS_EVENT_NAME}`,
},
{
type: 'mrkdwn',
text: `*Took:*\n${process.env.AS_TOOK}`,
},
]
}
]
}
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,6 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/workflow-notify
uses: ./.github/actions/workflow-notify-v2
with:
slack-webhook: ${{ secrets.E2E_REGULAR_SLACK_WEBHOOK }}
32 changes: 16 additions & 16 deletions .github/workflows/integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.fastai.result }}
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.kedro.result }}
Expand Down Expand Up @@ -168,7 +168,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.prophet.result }}
Expand Down Expand Up @@ -219,7 +219,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.keras.result }}
Expand Down Expand Up @@ -268,7 +268,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.lightning.result }}
Expand Down Expand Up @@ -317,7 +317,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.huggingface.result }}
Expand Down Expand Up @@ -363,7 +363,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.zenml.result }}
Expand Down Expand Up @@ -407,7 +407,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.mosaicml.result }}
Expand Down Expand Up @@ -454,7 +454,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.tensorflow-images.result }}
Expand Down Expand Up @@ -500,7 +500,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.detectron2.result }}
Expand Down Expand Up @@ -545,7 +545,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.rlang.result }}
Expand Down Expand Up @@ -591,7 +591,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.sklearn.result }}
Expand Down Expand Up @@ -637,7 +637,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.xgboost.result }}
Expand Down Expand Up @@ -683,7 +683,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.sacred.result }}
Expand Down Expand Up @@ -729,7 +729,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.mlflow.result }}
Expand Down Expand Up @@ -781,7 +781,7 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/job-notify
uses: ./.github/actions/job-notify-v2
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.airflow.result }}
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ jobs:
ref: ${{ needs.set_neptune_ref.outputs.neptune_ref }}

- name: Notify
uses: ./.github/actions/workflow-notify
uses: ./.github/actions/workflow-notify-v2
with:
slack-webhook: ${{ secrets.E2E_REGULAR_SLACK_WEBHOOK }}

0 comments on commit 16af9d9

Please sign in to comment.