-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathchat-example.yaml
118 lines (114 loc) · 5.46 KB
/
chat-example.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This example sends notifications Cloud Deploy events to a Google Chat
# space.
#
# This covers simple examples of notifying a chat space on new releases and
# being rollouts, created, started, etc.
#
globals:
chatSpace: "spaces/AAAA..."
serviceAccountEmail: [email protected]
statusToText:
Start: "started"
Succeed: "succeeded"
Failure: "failed"
Terminated: "was terminated"
Cancelled: "was cancelled"
pipeline:
# First example is for creation of a new release, which appears in clouddeploy-operations topic
- type: output.chat
config:
parent: "{{ chatSpace }}"
serviceAccountEmail: "{{ serviceAccountEmail }}"
runIf: |
{% if event.attributes.DeliveryPipelineId && event.attributes.ResourceType == "Release" && event.attributes.Action == "Succeeded" %}1{% endif %}
message:
cardsV2:
- cardId: new-release
card:
header:
title: A new release has been created!
subtitle: Google Cloud Deploy
imageUrl: https://lh3.googleusercontent.com/9E-FDrxYH-Q8I-eLLDljpdbpXd5Gt3oJqH1eN1vkV168sdFt1C2DwnVXzTaJb7ruqU35_RTPKQ=e14-rw-lo-sc0xffffff-h260-w204
imageType: CIRCLE
imageAltText: Google Cloud Deploy
sections:
- header: "Release details"
collapsible: true
uncollapsibleWidgetsCount: 4
widgets:
- decoratedText:
topLabel: "Release pipeline"
text: "{{ event.attributes.DeliveryPipelineId }}"
- decoratedText:
topLabel: "Release ID"
text: "{{ event.attributes.ReleaseId }}"
- decoratedText:
topLabel: "Location"
text: "{{ event.attributes.Location }}"
- buttonList:
buttons:
- text: View in console
onClick:
openLink:
url: |
https://console.cloud.google.com/deploy/delivery-pipelines/{{ event.attributes.Location }}/{{ event.attributes.DeliveryPipelineId }}/releases/{{ event.attributes.ReleaseId }}/rollouts?project={{ event.attributes.ProjectId }}
# Also can use a simpler text message:
#text: |
# 🚀 A new release has been created for *`{{ event.attributes.DeliveryPipelineId }}`*: `{{ event.attributes.ReleaseId }}` 🚀
# Second example is for a rollout of a release (eg. a deploy), appears in the clouddeploy-operations topic
- type: output.chat
config:
parent: "{{ chatSpace }}"
serviceAccountEmail: "{{ serviceAccountEmail }}"
runIf: |
{% if event.attributes.DeliveryPipelineId && event.attributes.ResourceType == "Rollout" && event.attributes.Action != "Started" %}1{% endif %}
message:
cardsV2:
- cardId: new-rollout
card:
header:
title: A rollout operation {{ statusToText[event.attributes.Action] }}.
subtitle: Google Cloud Deploy
imageUrl: https://lh3.googleusercontent.com/9E-FDrxYH-Q8I-eLLDljpdbpXd5Gt3oJqH1eN1vkV168sdFt1C2DwnVXzTaJb7ruqU35_RTPKQ=e14-rw-lo-sc0xffffff-h260-w204
imageType: CIRCLE
imageAltText: Google Cloud Deploy
sections:
- header: "Deployment details"
collapsible: true
uncollapsibleWidgetsCount: 6
widgets:
- decoratedText:
topLabel: "Target"
text: "{{ event.attributes.TargetId }}"
- decoratedText:
topLabel: "Rollout ID"
text: "{{ event.attributes.RolloutId }}"
- decoratedText:
topLabel: "Release pipeline"
text: "{{ event.attributes.DeliveryPipelineId }}"
- decoratedText:
topLabel: "Release ID"
text: "{{ event.attributes.ReleaseId }}"
- decoratedText:
topLabel: "Location"
text: "{{ event.attributes.Location }}"
- buttonList:
buttons:
- text: View in console
onClick:
openLink:
url: |
https://console.cloud.google.com/deploy/delivery-pipelines/{{ event.attributes.Location }}/{{ event.attributes.DeliveryPipelineId }}/releases/{{ event.attributes.ReleaseId }}/rollouts?project={{ event.attributes.ProjectId }}