Skip to content

Commit 719f718

Browse files
author
sangeet-joy_xero
committed
added slack alert composite action
1 parent 33559c3 commit 719f718

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

.github/actions/notify-slack.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: slack-alert-action
2+
description: "Action to send slack payload to public-sdk-events channel"
3+
4+
inputs:
5+
heading_text:
6+
required: true
7+
alert_type:
8+
required: true
9+
10+
runs:
11+
using: "composite"
12+
13+
steps:
14+
- name: Send slack notification
15+
id: slack
16+
uses: slackapi/slack-github-action@v1.27.0
17+
env:
18+
SLACK_WEBHOOK_URL: ""
19+
with:
20+
payload: |
21+
{
22+
"channel": "#public-sdk-events",
23+
"text": ${{inputs.heading_text}}
24+
"attachments": [
25+
{
26+
"color": ${{inputs.alert_type}},
27+
"fields": [
28+
{
29+
"title": "Repository",
30+
"value": "${{github.repository}}"
31+
"short": true
32+
},
33+
{
34+
"title": "Job",
35+
"value": ""
36+
"short": true
37+
},
38+
{
39+
"title": "commit",
40+
"value": "${{github.sha}}"
41+
"short": true
42+
},
43+
]
44+
}
45+
]
46+
}

.github/workflows/publish.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,18 @@ jobs:
3838
run: npm publish
3939
working-directory: xero-node
4040

41-
notify-slack:
41+
notify-slack-on-success:
4242
runs-on: ubuntu-latest
4343
needs: publish
44+
if: success()
4445
steps:
45-
- name: Send slack notification on sucess
46-
if: success()
46+
- name: Send slack notification on success
4747
run: echo "Slack alert on success"
4848

49+
notify-slack-on-failure:
50+
runs-on: ubuntu-latest
51+
needs: publish
52+
if: failure()
53+
steps:
4954
- name: Send slack notification on failure
50-
if: failure()
5155
run: echo "Slack alert on failure"

0 commit comments

Comments
 (0)