Skip to content

Commit 938764e

Browse files
authored
Add slack notifications for actions (#256)
1 parent fc52666 commit 938764e

File tree

2 files changed

+106
-1
lines changed

2 files changed

+106
-1
lines changed

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,73 @@ jobs:
8787
files: dist/*
8888
fail_on_unmatched_files: true
8989
generate_release_notes: true
90+
- name: Publish message to slack
91+
uses: slackapi/[email protected]
92+
if: success() && startsWith(github.ref, 'refs/tags/')
93+
with:
94+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
95+
webhook-type: incoming-webhook
96+
payload: |
97+
{
98+
"blocks": [
99+
{
100+
"type": "header",
101+
"text": {
102+
"type": "plain_text",
103+
"text": "✅ New codegen-sdk Release Successfully Published! 🚀",
104+
"emoji": true
105+
}
106+
},
107+
{
108+
"type": "section",
109+
"text": {
110+
"type": "mrkdwn",
111+
"text": "*Version:* ${{ github.ref_name }}\n*Released by:* <${{ github.server_url }}/${{ github.actor }}|@${{ github.actor }}>\n\n*Links:*\n• <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|GitHub Release>\n• <https://pypi.org/project/codegen-sdk/${{ github.ref_name }}|PyPI Package>"
112+
}
113+
},
114+
{
115+
"type": "context",
116+
"elements": [
117+
{
118+
"type": "mrkdwn",
119+
"text": "<!date^${{ github.event.release.published_at }}^Published {date_num} at {time}|Published just now>"
120+
}
121+
]
122+
}
123+
]
124+
}
125+
- name: Publish failed message to slack
126+
uses: slackapi/[email protected]
127+
if: failure() && startsWith(github.ref, 'refs/tags/')
128+
with:
129+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
130+
webhook-type: incoming-webhook
131+
payload: |
132+
{
133+
"blocks": [
134+
{
135+
"type": "header",
136+
"text": {
137+
"type": "plain_text",
138+
"text": "❌ codegen-sdk Release Failed",
139+
"emoji": true
140+
}
141+
},
142+
{
143+
"type": "section",
144+
"text": {
145+
"type": "mrkdwn",
146+
"text": "*Version:* ${{ github.ref_name }}\n*Attempted by:* <${{ github.server_url }}/${{ github.actor }}|@${{ github.actor }}>\n\n*Details:*\n• Failed to publish version ${{ github.ref_name }}\n• <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View workflow run>"
147+
}
148+
},
149+
{
150+
"type": "context",
151+
"elements": [
152+
{
153+
"type": "mrkdwn",
154+
"text": "Failed at <!date^${{ github.event.release.published_at }}^{date_num} {time}|just now>"
155+
}
156+
]
157+
}
158+
]
159+
}

.github/workflows/unit-tests.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
# changing the following value will significantly affect github's cost. Be careful and consult with the team before changing it.
9595
runs-on: ubuntu-latest-32
9696
if: contains(github.event.pull_request.labels.*.name, 'parse-tests') || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
97-
97+
environment: parse-tests
9898
steps:
9999
- uses: actions/checkout@v4
100100
- name: Setup backend
@@ -121,6 +121,41 @@ jobs:
121121
with:
122122
flag: no-flag
123123
codecov_token: ${{ secrets.CODECOV_TOKEN }}
124+
- name: Notify parse tests failure
125+
uses: slackapi/[email protected]
126+
if: failure() && github.event_name == 'push' && false
127+
with:
128+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
129+
webhook-type: incoming-webhook
130+
payload: |
131+
{
132+
"blocks": [
133+
{
134+
"type": "header",
135+
"text": {
136+
"type": "plain_text",
137+
"text": "❌ Parse Tests Failed",
138+
"emoji": true
139+
}
140+
},
141+
{
142+
"type": "section",
143+
"text": {
144+
"type": "mrkdwn",
145+
"text": "*Branch:* ${{ github.ref_name }}\n*Triggered by:* <${{ github.server_url }}/${{ github.actor }}|@${{ github.actor }}>\n\n*Details:*\n• <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View workflow run>"
146+
}
147+
},
148+
{
149+
"type": "context",
150+
"elements": [
151+
{
152+
"type": "mrkdwn",
153+
"text": "Failed at <!date^${{ github.event.head_commit.timestamp }}^{date_num} {time}|just now>"
154+
}
155+
]
156+
}
157+
]
158+
}
124159
# test_codemod_diffs:
125160
# # changing the following value will significantly affect github's cost. Be careful and consult with the team before changing it.
126161
# runs-on: ubuntu-latest-16

0 commit comments

Comments
 (0)