Skip to content

Commit 42f2921

Browse files
SCANPY-220 Fixed Slack notification on build failure. Added option to test if a Slack message is sent.
1 parent 94a7cc1 commit 42f2921

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

.github/workflows/MacOsNightly.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
required: false
1212
default: false
1313
type: boolean
14+
test_failure_notification:
15+
description: "Force a failure to test the Slack notification"
16+
required: false
17+
default: false
18+
type: boolean
1419

1520
# Only allow one instance of this workflow to run at a time
1621
concurrency:
@@ -43,6 +48,10 @@ jobs:
4348
- name: Execute the test suite
4449
run: poetry run pytest tests/
4550

51+
- name: "[Debug] Force failure to test Slack notification"
52+
if: ${{ inputs.test_failure_notification }}
53+
run: exit 1
54+
4655
its-macos:
4756
name: "macOS Integration Tests"
4857
runs-on: macos-latest-xlarge
@@ -89,7 +98,7 @@ jobs:
8998
id-token: write
9099
contents: read
91100
needs: [qa-macos, its-macos]
92-
if: failure() && github.event_name == 'schedule'
101+
if: failure() && (github.event_name == 'schedule' || inputs.test_failure_notification)
93102
steps:
94103
- name: Write failure summary
95104
run: |
@@ -99,10 +108,22 @@ jobs:
99108
echo "" >> $GITHUB_STEP_SUMMARY
100109
echo "**Workflow Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
101110
111+
- name: Vault Secrets
112+
id: secrets
113+
uses: SonarSource/vault-action-wrapper@v3
114+
with:
115+
secrets: |
116+
development/kv/data/slack token | SLACK_TOKEN;
117+
102118
- name: Send Slack notification
103-
uses: SonarSource/gh-action_slack-notify@1.0.1
119+
uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2.3.3
104120
env:
105-
GITHUB_TOKEN: ${{ github.token }}
106-
with:
107-
slackChannel: squad-python-notifs
121+
SLACK_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).SLACK_TOKEN }}
122+
SLACK_CHANNEL: squad-python-notifs
123+
SLACK_COLOR: danger
124+
SLACK_TITLE: Build Failed
125+
SLACK_MESSAGE: |
126+
Workflow failed in ${{ github.repository }} 🚨
127+
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
128+
SLACK_USERNAME: BuildBot
108129

0 commit comments

Comments
 (0)