-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
custom slack notification message 2/2 (#1792)
Co-authored-by: Szymon Sadkowski <[email protected]>
- Loading branch information
Showing
5 changed files
with
155 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`, | ||
}, | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`, | ||
}, | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters