-
Notifications
You must be signed in to change notification settings - Fork 1.8k
56 lines (54 loc) · 2.08 KB
/
slack-build-notifications.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Slack Build Notifications
on:
workflow_run:
workflows:
[
Add To Project,
Version,
Release,
Deploy React storybook to GitHub Pages,
promote,
]
types: [completed]
branches: [main]
jobs:
on-success:
runs-on: ubuntu-latest
# We only want notifications for successful runs for certain workflows
if:
${{ github.event.workflow_run.conclusion == 'success' &&
contains(fromJson('["Version", "Release", "Deploy React storybook to
GitHub Pages", "promote"]'), github.event.workflow.name) }}
steps:
- name: Send custom JSON data to Slack
id: slack-success
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
with:
payload: |
{
"username": "Workflow succeeded ✅",
"icon_url": "https://user-images.githubusercontent.com/3360588/192045905-5d9705af-92e2-4432-805e-15db98571e8b.png",
"channel": "#carbon-system-notifications",
"text": "The ${{ github.event.workflow.name }} workflow succeeded: ${{ github.event.workflow_run.url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: Send custom JSON data to Slack
id: slack-failure
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
with:
payload: |
{
"username": "Workflow failed 🚫",
"icon_url": "https://user-images.githubusercontent.com/3360588/192045905-5d9705af-92e2-4432-805e-15db98571e8b.png",
"channel": "#carbon-system-notifications",
"text": "The ${{ github.event.workflow.name }} workflow failed: ${{ github.event.workflow_run.url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK