Skip to content

Commit b1d18b0

Browse files
committed
Add Slack notification and simplify names
1 parent f250a32 commit b1d18b0

1 file changed

Lines changed: 56 additions & 1 deletion

File tree

.github/workflows/standalone_test.yml

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,63 @@ jobs:
7676
timeout-minutes: 15
7777

7878
# Trigger standalone package tests:
79-
- name: 'Trigger standalone package tests'
79+
- name: 'Trigger tests'
8080
env:
8181
GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
8282
run: |
8383
node lib/node_modules/@stdlib/_tools/scripts/trigger_workflow_events.js
84+
85+
# Define a job for sending notifications to Slack...
86+
slack:
87+
88+
# Define a display name:
89+
name: 'Slack notification'
90+
91+
# Define the type of virtual host machine:
92+
runs-on: 'ubuntu-latest'
93+
94+
# Indicate that this job depends on the prior job finishing:
95+
needs: trigger
96+
97+
# Run this job regardless of the outcome of the prior job:
98+
if: always()
99+
100+
# Set defaults:
101+
defaults:
102+
run:
103+
# Set the default shell to `bash`:
104+
shell: bash --noprofile --norc -eo pipefail {0}
105+
106+
# Define the sequence of job steps...
107+
steps:
108+
109+
# Resolve notification data:
110+
- name: 'Resolve notification data'
111+
run: |
112+
echo 'NOTIFICATION_STATUS=${{ needs.trigger.result}}' >> $GITHUB_ENV
113+
if [[ "${{ needs.trigger.result }}" = "success" ]]; then
114+
echo 'NOTIFICATION_TEXT=**standalone_test** workflow succeeded' >> $GITHUB_ENV
115+
echo 'NOTIFICATION_AUTHOR_NAME=Success' >> $GITHUB_ENV
116+
elif [[ "${{ needs.trigger.result }}" = "failure" ]]; then
117+
echo 'NOTIFICATION_TEXT=**standalone_test** workflow failed' >> $GITHUB_ENV
118+
echo 'NOTIFICATION_AUTHOR_NAME=Failure' >> $GITHUB_ENV
119+
elif [[ "${{ needs.trigger.result }}" = "cancelled" ]]; then
120+
echo 'NOTIFICATION_TEXT=**standalone_test** workflow was canceled' >> $GITHUB_ENV
121+
echo 'NOTIFICATION_AUTHOR_NAME=Canceled' >> $GITHUB_ENV
122+
else
123+
exit 1
124+
fi
125+
timeout-minutes: 5
126+
127+
# Send notification to Slack:
128+
- name: 'Send notification'
129+
uses: 8398a7/action-slack@v3
130+
if: success()
131+
with:
132+
status: "${{ env.NOTIFICATION_STATUS }}"
133+
fields: repo,commit,message
134+
text: "${{ env.NOTIFICATION_TEXT }}"
135+
author_name: "${{ env.NOTIFICATION_AUTHOR_NAME }}"
136+
env:
137+
SLACK_WEBHOOK_URL: ${{ secrets.REPO_SLACK_WEBHOOK_URL }}
138+
timeout-minutes: 5

0 commit comments

Comments
 (0)