forked from krumIO/cloud-native-cicd-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCI_Notifications_Workflow.yaml
49 lines (49 loc) · 1.31 KB
/
CI_Notifications_Workflow.yaml
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
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: slack-notification-
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: do-something
template: do-something
- - name: notify-success
template: slack-notify
arguments:
parameters:
- name: status
value: "Success"
when: "{{steps.do-something.exitCode}} == 0"
- name: notify-failure
template: slack-notify
arguments:
parameters:
- name: status
value: "Failure"
when: "{{steps.do-something.exitCode}} != 0"
- name: do-something
script:
image: debian:9
command: [bash]
source: |
# Do something here
- name: slack-notify
inputs:
parameters:
- name: status
script:
image: curlimages/curl:7.72.0
command: [bash]
source: |
curl -X POST -H 'Authorization: Bearer $(cat /etc/slack/token)' -H 'Content-type: application/json' \
--data '{"channel":"david-argo-notis","text":"Workflow {{workflow.name}} ended with status: {{inputs.parameters.status}}"}' \
https://slack.com/api/chat.postMessage
volumeMounts:
- name: slack
mountPath: /etc/slack
volumes:
- name: slack
secret:
secretName: slack-token