Skip to content

Commit 83c31d0

Browse files
authored
Merge pull request #243 from Scale3-Labs/add-slack-workflow-alerting
feat: add slack notification for workflows
2 parents 88d1ba2 + 6124dfc commit 83c31d0

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"attachments": [
3+
{
4+
"pretext": "{{ env.PRE_TEXT_MESSAGE }}",
5+
"fallback": "{{ env.FALLBACK_MESSAGE }}",
6+
"color": "{{ env.COLOR }}",
7+
"author_name": "{{ github.workflow }}",
8+
"author_link": "{{ env.GITHUB_SERVER_URL }}/{{ env.GITHUB_REPOSITORY }}/actions/runs/{{ env.GITHUB_RUN_ID }}",
9+
"title": "{{ env.GITHUB_REPOSITORY }}",
10+
"title_link": "{{ env.GITHUB_SERVER_URL }}/{{ env.GITHUB_REPOSITORY }}",
11+
"fields": [
12+
{
13+
"title": "Release Tag",
14+
"short": true,
15+
"value": "{{ env.RELEASETAG }}"
16+
}
17+
],
18+
"footer": "deployed by: {{ github.actor }}",
19+
"footer_icon": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
20+
}
21+
]
22+
}

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,39 @@ jobs:
6868
uses: pypa/gh-action-pypi-publish@master
6969
with:
7070
password: ${{ secrets.PYPI_TOKEN }}
71+
72+
post-release:
73+
name: Post Release Actions
74+
75+
runs-on: ubuntu-latest
76+
if: ${{ always() }}
77+
needs:
78+
- generate-version
79+
- publish
80+
81+
steps:
82+
- name: Slack - Success Message
83+
uses: DSdatsme/slack-github-action@env_support
84+
if: ${{ success() && needs.publish.result == 'success' }}
85+
with:
86+
channel-id: ${{ vars.SLACK_CHANNEL_ID }}
87+
payload-file-path: ./.github/resources/slack-payloads/slack-message-template.json
88+
env:
89+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
90+
RELEASETAG: ${{ needs.generate-version.outputs.new_version }}
91+
PRE_TEXT_MESSAGE: "Workflow Passed! :successkid:"
92+
FALLBACK_MESSAGE: "Workflow Passed!"
93+
COLOR: "good"
94+
95+
- name: Slack - Failure Message
96+
uses: DSdatsme/slack-github-action@env_support
97+
if: ${{ failure() || needs.publish.result != 'success' }}
98+
with:
99+
channel-id: ${{ vars.SLACK_CHANNEL_ID }}
100+
payload-file-path: ./.github/resources/slack-payloads/slack-message-template.json
101+
env:
102+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
103+
RELEASETAG: ${{ needs.generate-version.outputs.new_version }}
104+
PRE_TEXT_MESSAGE: "<!channel> Workflow Failed! :x:"
105+
FALLBACK_MESSAGE: "Workflow Failed!"
106+
COLOR: "danger"

0 commit comments

Comments
 (0)