Skip to content

Commit 8304d0a

Browse files
add notifications
1 parent a240002 commit 8304d0a

File tree

1 file changed

+221
-1
lines changed

1 file changed

+221
-1
lines changed

.github/workflows/release.yaml

Lines changed: 221 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
- name: Install dependencies
2525
run: |
26-
pip install --quiet build twine
26+
pip install --quiet build twine toml
2727
2828
- name: Modify package name for beta
2929
run: |
@@ -38,6 +38,119 @@ jobs:
3838
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
3939
run: |
4040
twine upload dist/*
41+
42+
- name: Get version for beta
43+
if: always()
44+
id: get_beta_version
45+
run: |
46+
VERSION=$(python3 -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
47+
echo "version=$VERSION" >> $GITHUB_OUTPUT
48+
49+
- name: Send Slack notification on success
50+
if: success()
51+
uses: slackapi/slack-github-action@v1
52+
with:
53+
payload: |
54+
{
55+
"text": "✅ SUCCESSFUL: Beta Release ${{ steps.get_beta_version.outputs.version }}",
56+
"blocks": [
57+
{
58+
"type": "section",
59+
"text": {
60+
"type": "mrkdwn",
61+
"text": "*Beta Release Successful* ✅\n*Version:* ${{ steps.get_beta_version.outputs.version }}\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}\n*Message:* ${{ github.event.head_commit.message }}"
62+
}
63+
}
64+
]
65+
}
66+
env:
67+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
68+
continue-on-error: true
69+
70+
- name: Send Slack notification on failure
71+
if: failure()
72+
uses: slackapi/slack-github-action@v1
73+
with:
74+
payload: |
75+
{
76+
"text": "❌ FAILED: Beta Release",
77+
"blocks": [
78+
{
79+
"type": "section",
80+
"text": {
81+
"type": "mrkdwn",
82+
"text": "*Beta Release Failed* ❌\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}\n*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"
83+
}
84+
}
85+
]
86+
}
87+
env:
88+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
89+
continue-on-error: true
90+
91+
- name: Send Slack notification on cancellation
92+
if: cancelled()
93+
uses: slackapi/slack-github-action@v1
94+
with:
95+
payload: |
96+
{
97+
"text": "⚠️ ABORTED: Beta Release",
98+
"blocks": [
99+
{
100+
"type": "section",
101+
"text": {
102+
"type": "mrkdwn",
103+
"text": "*Beta Release Aborted* ⚠️\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}"
104+
}
105+
}
106+
]
107+
}
108+
env:
109+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
110+
continue-on-error: true
111+
112+
- name: Send email notification on success
113+
if: success()
114+
uses: dawidd6/action-send-mail@v3
115+
with:
116+
server_address: smtp.gmail.com
117+
server_port: 587
118+
username: ${{ secrets.EMAIL_USERNAME }}
119+
password: ${{ secrets.EMAIL_PASSWORD }}
120+
subject: "SUCCESSFUL: Beta Release '${{ github.repository }}' [Build #${{ github.run_number }}]"
121+
122+
from: GitHub Actions <[email protected]>
123+
body: |
124+
SUCCESSFUL: Beta Release '${{ github.repository }}' [Build #${{ github.run_number }}]
125+
126+
Version: ${{ steps.get_beta_version.outputs.version }}
127+
Branch: ${{ github.ref_name }}
128+
Commit: ${{ github.sha }}
129+
Author: ${{ github.event.head_commit.author.name }}
130+
131+
Check workflow run at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
132+
continue-on-error: true
133+
134+
- name: Send email notification on failure
135+
if: failure()
136+
uses: dawidd6/action-send-mail@v3
137+
with:
138+
server_address: smtp.gmail.com
139+
server_port: 587
140+
username: ${{ secrets.EMAIL_USERNAME }}
141+
password: ${{ secrets.EMAIL_PASSWORD }}
142+
subject: "FAILED: Beta Release '${{ github.repository }}' [Build #${{ github.run_number }}]"
143+
144+
from: GitHub Actions <[email protected]>
145+
body: |
146+
FAILED: Beta Release '${{ github.repository }}' [Build #${{ github.run_number }}]
147+
148+
Branch: ${{ github.ref_name }}
149+
Commit: ${{ github.sha }}
150+
Author: ${{ github.event.head_commit.author.name }}
151+
152+
Check console output at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
153+
continue-on-error: true
41154

42155
prod-release:
43156
name: Production Release
@@ -92,3 +205,110 @@ jobs:
92205
env:
93206
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94207

208+
- name: Send Slack notification on success
209+
if: success()
210+
uses: slackapi/slack-github-action@v1
211+
with:
212+
payload: |
213+
{
214+
"text": "✅ SUCCESSFUL: Production Release ${{ steps.get_version.outputs.version }}",
215+
"blocks": [
216+
{
217+
"type": "section",
218+
"text": {
219+
"type": "mrkdwn",
220+
"text": "*Production Release Successful* ✅\n*Version:* ${{ steps.get_version.outputs.version }}\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}\n*Message:* ${{ github.event.head_commit.message }}\n*Release:* <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.version }}|View Release>"
221+
}
222+
}
223+
]
224+
}
225+
env:
226+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
227+
continue-on-error: true
228+
229+
- name: Send Slack notification on failure
230+
if: failure()
231+
uses: slackapi/slack-github-action@v1
232+
with:
233+
payload: |
234+
{
235+
"text": "❌ FAILED: Production Release",
236+
"blocks": [
237+
{
238+
"type": "section",
239+
"text": {
240+
"type": "mrkdwn",
241+
"text": "*Production Release Failed* ❌\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}\n*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"
242+
}
243+
}
244+
]
245+
}
246+
env:
247+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
248+
continue-on-error: true
249+
250+
- name: Send Slack notification on cancellation
251+
if: cancelled()
252+
uses: slackapi/slack-github-action@v1
253+
with:
254+
payload: |
255+
{
256+
"text": "⚠️ ABORTED: Production Release",
257+
"blocks": [
258+
{
259+
"type": "section",
260+
"text": {
261+
"type": "mrkdwn",
262+
"text": "*Production Release Aborted* ⚠️\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Commit:* <${{ github.event.head_commit.url }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}"
263+
}
264+
}
265+
]
266+
}
267+
env:
268+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
269+
continue-on-error: true
270+
271+
- name: Send email notification on success
272+
if: success()
273+
uses: dawidd6/action-send-mail@v3
274+
with:
275+
server_address: smtp.gmail.com
276+
server_port: 587
277+
username: ${{ secrets.EMAIL_USERNAME }}
278+
password: ${{ secrets.EMAIL_PASSWORD }}
279+
subject: "SUCCESSFUL: Production Release '${{ github.repository }}' [Build #${{ github.run_number }}]"
280+
281+
from: GitHub Actions <[email protected]>
282+
body: |
283+
SUCCESSFUL: Production Release '${{ github.repository }}' [Build #${{ github.run_number }}]
284+
285+
Version: ${{ steps.get_version.outputs.version }}
286+
Branch: ${{ github.ref_name }}
287+
Commit: ${{ github.sha }}
288+
Author: ${{ github.event.head_commit.author.name }}
289+
290+
Check workflow run at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
291+
View Release at: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.version }}
292+
continue-on-error: true
293+
294+
- name: Send email notification on failure
295+
if: failure()
296+
uses: dawidd6/action-send-mail@v3
297+
with:
298+
server_address: smtp.gmail.com
299+
server_port: 587
300+
username: ${{ secrets.EMAIL_USERNAME }}
301+
password: ${{ secrets.EMAIL_PASSWORD }}
302+
subject: "FAILED: Production Release '${{ github.repository }}' [Build #${{ github.run_number }}]"
303+
304+
from: GitHub Actions <[email protected]>
305+
body: |
306+
FAILED: Production Release '${{ github.repository }}' [Build #${{ github.run_number }}]
307+
308+
Branch: ${{ github.ref_name }}
309+
Commit: ${{ github.sha }}
310+
Author: ${{ github.event.head_commit.author.name }}
311+
312+
Check console output at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
313+
continue-on-error: true
314+

0 commit comments

Comments
 (0)