Skip to content

Commit 54de4a7

Browse files
authored
Use new Slack message sender in reusable-actions #3903 (#547)
* Added reusable actions for slack notification on failure in CI run * Use workflow in reusable-actions repo * Use reusable workflow and make integration test fail * Separate job for slack notification in each workflow * Removed unnecessary permission
1 parent eca8fdf commit 54de4a7

4 files changed

Lines changed: 68 additions & 41 deletions

File tree

.github/workflows/daily-cli-tests.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,21 @@ jobs:
4848
kosli_reporting_api_token: ${{ secrets.KOSLI_PUBLIC_API_TOKEN }}
4949
kosli_querying_api_token: ${{ secrets.KOSLI_API_TOKEN_PROD }}
5050
sonarqube_token: ${{ secrets.KOSLI_SONARQUBE_TOKEN }}
51+
52+
slack-notification-on-failure:
53+
runs-on: ubuntu-24.04
54+
permissions:
55+
actions: read
56+
contents: read
57+
needs:
58+
[
59+
set-trail-name,
60+
test,
61+
]
62+
if: ${{ always() && contains(join(needs.*.result, ','), 'failure') && github.ref == 'refs/heads/master' }}
63+
steps:
64+
- name: Slack Notification on Failure
65+
uses: kosli-dev/reusable-actions/.github/actions/send-ci-failure-slack-message@main
66+
with:
67+
slack_url: ${{ secrets.MERKELY_SLACK_CI_FAILURES_WEBHOOK }}
68+
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,23 @@ jobs:
8888
slack_channel: ci-failures
8989
kosli_api_token: ${{ secrets.KOSLI_PUBLIC_API_TOKEN }}
9090
snyk_token: ${{ secrets.SNYK_TOKEN }}
91+
92+
slack-notification-on-failure:
93+
runs-on: ubuntu-24.04
94+
permissions:
95+
actions: read
96+
contents: read
97+
needs:
98+
[
99+
pre-build,
100+
init-kosli,
101+
test,
102+
docker
103+
]
104+
if: ${{ always() && contains(join(needs.*.result, ','), 'failure') && github.ref == 'refs/heads/master' }}
105+
steps:
106+
- name: Slack Notification on Failure
107+
uses: kosli-dev/reusable-actions/.github/actions/send-ci-failure-slack-message@main
108+
with:
109+
slack_url: ${{ secrets.MERKELY_SLACK_CI_FAILURES_WEBHOOK }}
110+
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,31 @@ jobs:
250250
tag: ${{ needs.pre-build.outputs.tag }}
251251
AWS_ACCOUNT_ID: 585008075785
252252
AWS_REGION: eu-central-1
253+
254+
slack-notification-on-failure:
255+
runs-on: ubuntu-24.04
256+
permissions:
257+
actions: read
258+
contents: read
259+
needs:
260+
[
261+
pre-build,
262+
init-kosli,
263+
never-alone-trail,
264+
test,
265+
docker,
266+
goreleaser,
267+
binary-provenance,
268+
homebrew-pr,
269+
docs-gen,
270+
evidence-reporter-upload-package-and-deploy,
271+
environment-reporter-upload-package-and-deploy,
272+
environment-reporter-upload-layer
273+
]
274+
if: ${{ always() && contains(join(needs.*.result, ','), 'failure') && github.ref == 'refs/heads/master' }}
275+
steps:
276+
- name: Slack Notification on Failure
277+
uses: kosli-dev/reusable-actions/.github/actions/send-ci-failure-slack-message@main
278+
with:
279+
slack_url: ${{ secrets.MERKELY_SLACK_CI_FAILURES_WEBHOOK }}
280+
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,7 @@ jobs:
9797
--flow ${{ inputs.FLOW_NAME }}
9898
--trail ${{ inputs.TRAIL_NAME }}
9999
--org ${{ inputs.KOSLI_ORG }}
100-
--compliant=${{ steps.lint.outcome == 'success' }}
101-
102-
- name: Slack Notification on Failure
103-
if: ${{ failure() }}
104-
uses: rtCamp/action-slack-notify@v2
105-
env:
106-
SLACK_CHANNEL: ${{ secrets.slack_channel }}
107-
SLACK_COLOR: ${{ job.status }}
108-
SLACK_TITLE: Lint Failed in CLI repository
109-
SLACK_USERNAME: GithubActions
110-
SLACK_WEBHOOK: ${{ secrets.slack_webhook }}
100+
--compliant=${{ steps.lint.outcome == 'success' }}
111101

112102
test:
113103
name: Test
@@ -176,16 +166,6 @@ jobs:
176166
if: ${{ inputs.report_results }}
177167
uses: codecov/codecov-action@v4
178168

179-
- name: Slack Notification on Failure
180-
if: ${{ failure() }}
181-
uses: rtCamp/action-slack-notify@v2
182-
env:
183-
SLACK_CHANNEL: ${{ secrets.slack_channel }}
184-
SLACK_COLOR: ${{ job.status }}
185-
SLACK_TITLE: Test Failed in CLI repository
186-
SLACK_USERNAME: GithubActions
187-
SLACK_WEBHOOK: ${{ secrets.slack_webhook }}
188-
189169
snyk-code-test:
190170
if: ${{ inputs.run_snyk }}
191171
name: Snyk Code Test
@@ -222,16 +202,6 @@ jobs:
222202
# --trail ${{ inputs.TRAIL_NAME }}
223203
# --scan-results snyk-code.json
224204
# --org ${{ inputs.KOSLI_ORG }}
225-
226-
# - name: Slack Notification on Failure
227-
# if: ${{ failure() }}
228-
# uses: rtCamp/action-slack-notify@v2
229-
# env:
230-
# SLACK_CHANNEL: ${{ secrets.slack_channel }}
231-
# SLACK_COLOR: ${{ job.status }}
232-
# SLACK_TITLE: Snyk Code Failed in CLI repository
233-
# SLACK_USERNAME: GithubActions
234-
# SLACK_WEBHOOK: ${{ secrets.slack_webhook }}
235205

236206
snyk-dependency-test:
237207
if: ${{ inputs.run_snyk }}
@@ -269,13 +239,4 @@ jobs:
269239
# --trail ${{ inputs.TRAIL_NAME }}
270240
# --scan-results snyk-dependency.json
271241
# --org ${{ inputs.KOSLI_ORG }}
272-
273-
# - name: Slack Notification on Failure
274-
# if: ${{ failure() }}
275-
# uses: rtCamp/action-slack-notify@v2
276-
# env:
277-
# SLACK_CHANNEL: ${{ secrets.slack_channel }}
278-
# SLACK_COLOR: ${{ job.status }}
279-
# SLACK_TITLE: Snyk Test Failed in CLI repository
280-
# SLACK_USERNAME: GithubActions
281-
# SLACK_WEBHOOK: ${{ secrets.slack_webhook }}
242+

0 commit comments

Comments
 (0)