Skip to content

Commit 2f0cd31

Browse files
committed
Add Slack notification
1 parent ff8381b commit 2f0cd31

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/standalone_publish.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,58 @@ jobs:
9393
path: |
9494
/tmp/stdlib_ordered_pkg_list.json
9595
/tmp/stdlib_published_pkg_list.json
96+
97+
# Define a job for sending notifications to Slack...
98+
slack:
99+
100+
# Define a display name:
101+
name: 'Slack notification'
102+
103+
# Define the type of virtual host machine:
104+
runs-on: 'ubuntu-latest'
105+
106+
# Indicate that this job depends on the prior job finishing:
107+
needs: publish
108+
109+
# Run this job regardless of the outcome of the prior job:
110+
if: always()
111+
112+
# Set defaults:
113+
defaults:
114+
run:
115+
# Set the default shell to `bash`:
116+
shell: bash --noprofile --norc -eo pipefail {0}
117+
118+
# Define the sequence of job steps...
119+
steps:
120+
121+
# Resolve notification data:
122+
- name: 'Resolve notification data'
123+
run: |
124+
echo 'NOTIFICATION_STATUS=${{ needs.publish.result}}' >> $GITHUB_ENV
125+
if [[ "${{ needs.publish.result }}" = "success" ]]; then
126+
echo 'NOTIFICATION_TEXT=**standalone_publish** workflow succeeded' >> $GITHUB_ENV
127+
echo 'NOTIFICATION_AUTHOR_NAME=Success' >> $GITHUB_ENV
128+
elif [[ "${{ needs.publish.result }}" = "failure" ]]; then
129+
echo 'NOTIFICATION_TEXT=**standalone_publish** workflow failed' >> $GITHUB_ENV
130+
echo 'NOTIFICATION_AUTHOR_NAME=Failure' >> $GITHUB_ENV
131+
elif [[ "${{ needs.publish.result }}" = "cancelled" ]]; then
132+
echo 'NOTIFICATION_TEXT=**standalone_publish** workflow was canceled' >> $GITHUB_ENV
133+
echo 'NOTIFICATION_AUTHOR_NAME=Canceled' >> $GITHUB_ENV
134+
else
135+
exit 1
136+
fi
137+
timeout-minutes: 5
138+
139+
# Send notification to Slack:
140+
- name: 'Send notification'
141+
uses: 8398a7/action-slack@v3
142+
if: success()
143+
with:
144+
status: "${{ env.NOTIFICATION_STATUS }}"
145+
fields: repo,commit,message
146+
text: "${{ env.NOTIFICATION_TEXT }}"
147+
author_name: "${{ env.NOTIFICATION_AUTHOR_NAME }}"
148+
env:
149+
SLACK_WEBHOOK_URL: ${{ secrets.REPO_SLACK_WEBHOOK_URL }}
150+
timeout-minutes: 5

0 commit comments

Comments
 (0)