Skip to content

Commit fe8d709

Browse files
committed
fix(ci): skip Slack notification when SLACK_WEBHOOK_OSS_ALERTS is not set
1 parent da02c95 commit fe8d709

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

.github/workflows/showcase_docs-sync.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
pull-requests: write
2222
env:
2323
SHOWCASE_BRANCH: main
24+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}
2425
steps:
2526
- uses: actions/checkout@v4
2627
with:
@@ -364,7 +365,7 @@ jobs:
364365
365366
- name: Notify Slack (auto-sync)
366367
id: notify-auto-sync
367-
if: always() && steps.push.outcome == 'success' && steps.push.outputs.files_changed != '0' && steps.push.outputs.needs_review != 'true'
368+
if: always() && env.SLACK_WEBHOOK != '' && steps.push.outcome == 'success' && steps.push.outputs.files_changed != '0' && steps.push.outputs.needs_review != 'true'
368369
uses: slackapi/slack-github-action@v2.1.0
369370
with:
370371
webhook: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}
@@ -373,7 +374,7 @@ jobs:
373374

374375
- name: Notify Slack (merge failed)
375376
id: notify-merge-failed
376-
if: failure() && steps.push.outputs.pr_opened == 'true' && steps.push.outputs.needs_review != 'true'
377+
if: failure() && env.SLACK_WEBHOOK != '' && steps.push.outputs.pr_opened == 'true' && steps.push.outputs.needs_review != 'true'
377378
uses: slackapi/slack-github-action@v2.1.0
378379
with:
379380
webhook: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}
@@ -387,7 +388,7 @@ jobs:
387388
# PR URL (not on any error path that leaves pr_url empty).
388389
- name: Notify Slack (review needed, with PR)
389390
id: notify-review-with-pr
390-
if: always() && steps.push.outputs.needs_review == 'true' && steps.push.outputs.pr_opened == 'true'
391+
if: always() && env.SLACK_WEBHOOK != '' && steps.push.outputs.needs_review == 'true' && steps.push.outputs.pr_opened == 'true'
391392
uses: slackapi/slack-github-action@v2.1.0
392393
with:
393394
webhook: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}
@@ -400,7 +401,7 @@ jobs:
400401
# the existing-PR collision path, which gets its own step below.
401402
- name: Notify Slack (review needed, no PR)
402403
id: notify-review-no-pr
403-
if: always() && steps.sync.outputs.action == 'push_and_pr' && steps.push.outputs.pr_opened == 'false' && steps.push.outputs.existing_pr != 'true'
404+
if: always() && env.SLACK_WEBHOOK != '' && steps.sync.outputs.action == 'push_and_pr' && steps.push.outputs.pr_opened == 'false' && steps.push.outputs.existing_pr != 'true'
404405
uses: slackapi/slack-github-action@v2.1.0
405406
with:
406407
webhook: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}
@@ -411,7 +412,7 @@ jobs:
411412
# needs-review PR already exists — point reviewers at it.
412413
- name: Notify Slack (review needed, existing PR)
413414
id: notify-review-existing-pr
414-
if: always() && steps.push.outputs.existing_pr == 'true'
415+
if: always() && env.SLACK_WEBHOOK != '' && steps.push.outputs.existing_pr == 'true'
415416
uses: slackapi/slack-github-action@v2.1.0
416417
with:
417418
webhook: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}
@@ -420,7 +421,7 @@ jobs:
420421

421422
- name: Notify Slack (failure)
422423
id: notify-failure
423-
if: failure() && steps.push.outputs.pr_opened != 'true'
424+
if: failure() && env.SLACK_WEBHOOK != '' && steps.push.outputs.pr_opened != 'true'
424425
uses: slackapi/slack-github-action@v2.1.0
425426
with:
426427
webhook: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}
@@ -440,7 +441,7 @@ jobs:
440441
# values cannot contain " or \.
441442
- name: Notify Slack (alert machinery failed)
442443
if: >-
443-
always() && (
444+
always() && env.SLACK_WEBHOOK != '' && (
444445
steps.notify-auto-sync.outcome == 'failure' ||
445446
steps.notify-merge-failed.outcome == 'failure' ||
446447
steps.notify-review-with-pr.outcome == 'failure' ||

.github/workflows/showcase_qa-sync.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
name: Sync QA Instructions
1919
runs-on: ubuntu-latest
2020
timeout-minutes: 10
21+
env:
22+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}
2123

2224
steps:
2325
- name: Checkout
@@ -46,7 +48,7 @@ jobs:
4648
run: npx tsx sync-qa-to-notion.ts
4749

4850
- name: Notify Slack (failure)
49-
if: failure()
51+
if: failure() && env.SLACK_WEBHOOK != ''
5052
uses: slackapi/slack-github-action@v2.1.0
5153
with:
5254
webhook: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}

.github/workflows/test_smoke-starter.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
smoke-starter:
2222
runs-on: ubuntu-latest
2323
timeout-minutes: 20
24+
env:
25+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}
2426
strategy:
2527
matrix:
2628
starter:
@@ -137,7 +139,7 @@ jobs:
137139
# same pattern used in test_smoke-starter-deployed.yml (PR #4068) and
138140
# showcase_validate.yml.
139141
- name: Prepare Slack alert fields
140-
if: failure() && (github.event_name == 'schedule' || github.event_name == 'workflow_run')
142+
if: failure() && env.SLACK_WEBHOOK != '' && (github.event_name == 'schedule' || github.event_name == 'workflow_run')
141143
env:
142144
SUMMARY_RAW: ${{ steps.failure-cause.outputs.summary }}
143145
run: |
@@ -158,7 +160,7 @@ jobs:
158160
} >> "$GITHUB_ENV"
159161
160162
- name: Alert Slack on failure
161-
if: failure() && (github.event_name == 'schedule' || github.event_name == 'workflow_run')
163+
if: failure() && env.SLACK_WEBHOOK != '' && (github.event_name == 'schedule' || github.event_name == 'workflow_run')
162164
uses: slackapi/slack-github-action@v2.1.0
163165
with:
164166
webhook: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}

0 commit comments

Comments
 (0)