Skip to content

Commit 5e0e99d

Browse files
authored
Add a Slack notify step in CI
1 parent b106171 commit 5e0e99d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,39 @@ jobs:
203203
password: "${{ secrets.PYPI_API_TOKEN }}"
204204
needs:
205205
- "unittest"
206+
slack-notify:
207+
needs:
208+
- "publish_gh"
209+
- "publish_pypi"
210+
name: "Send notification to the Slack"
211+
runs-on: "ubuntu-20.04"
212+
env:
213+
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
214+
SLACK_MESSAGE: >-
215+
*NOTIFICATION: NEW-RELEASE-PUBLISHED*\n
216+
Repository: <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>\n
217+
Release: <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|${{ github.ref_name }}>\n
218+
Published by: <${{ github.server_url }}/${{ github.actor }}|${{ github.actor }}>
219+
steps:
220+
- name: "Send a notification to Slack"
221+
# ENVs cannot be used directly in job.if. This is a workaround to check
222+
# if SLACK_WEBHOOK_URL is present.
223+
if: "${{ env.SLACK_WEBHOOK_URL != '' }}"
224+
uses: "slackapi/[email protected]"
225+
with:
226+
payload: |
227+
{
228+
"text": "${{ env.SLACK_MESSAGE }}",
229+
"blocks": [
230+
{
231+
"type": "section",
232+
"text": {
233+
"type": "mrkdwn",
234+
"text": "${{ env.SLACK_MESSAGE }}"
235+
}
236+
}
237+
]
238+
}
239+
env:
240+
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
241+
SLACK_WEBHOOK_TYPE: "INCOMING_WEBHOOK"

0 commit comments

Comments
 (0)