Skip to content

Commit 9b8ea98

Browse files
committed
Add Slack notification
1 parent 2f0cd31 commit 9b8ea98

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/standalone_push_changes.yml

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

0 commit comments

Comments
 (0)