Skip to content

Commit 898e089

Browse files
authored
Update ci.yml
1 parent c2707f3 commit 898e089

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: "CI"
3-
on:
3+
on: # yamllint disable-line rule:truthy
44
- "push"
55
- "pull_request"
66
jobs:
@@ -170,3 +170,39 @@ jobs:
170170
password: "${{ secrets.PYPI_API_TOKEN }}"
171171
needs:
172172
- "unittest"
173+
slack-notify:
174+
needs:
175+
- "publish_gh"
176+
- "publish_pypi"
177+
name: "Send notification to the Slack"
178+
runs-on: "ubuntu-20.04"
179+
env:
180+
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
181+
SLACK_MESSAGE: >-
182+
*NOTIFICATION: NEW-RELEASE-PUBLISHED*\n
183+
Repository: <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>\n
184+
Release: <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|${{ github.ref_name }}>\n
185+
Published by: <${{ github.server_url }}/${{ github.actor }}|${{ github.actor }}>
186+
steps:
187+
- name: "Send a notification to Slack"
188+
# ENVs cannot be used directly in job.if. This is a workaround to check
189+
# if SLACK_WEBHOOK_URL is present.
190+
if: "${{ env.SLACK_WEBHOOK_URL != '' }}"
191+
uses: "slackapi/[email protected]"
192+
with:
193+
payload: |
194+
{
195+
"text": "${{ env.SLACK_MESSAGE }}",
196+
"blocks": [
197+
{
198+
"type": "section",
199+
"text": {
200+
"type": "mrkdwn",
201+
"text": "${{ env.SLACK_MESSAGE }}"
202+
}
203+
}
204+
]
205+
}
206+
env:
207+
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
208+
SLACK_WEBHOOK_TYPE: "INCOMING_WEBHOOK"

0 commit comments

Comments
 (0)