-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcodefresh_color.yaml
More file actions
272 lines (253 loc) · 6.81 KB
/
Copy pathcodefresh_color.yaml
File metadata and controls
272 lines (253 loc) · 6.81 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
version: "1.0"
stages:
- clone
- build
- metadata
- dev
- qa
- europe
- us
hooks:
on_fail:
steps:
exec:
type: slack-post-channel:0.0.7
arguments:
SLACK_TOKEN: ${{LR_SLACK_TOKEN}}
SLACK_CHANNEL: ${{SLACK_CHANNEL}}
SLACK_MESSAGE: "CICD build for color failed. See ${{CF_BUILD_URL}}"
when:
condition:
all:
alert: "'${{SLACK_ALERT}}' == 'true'"
steps:
clone:
title: "Cloning repository"
stage: clone
type: "git-clone"
depth: 1
exclude_blobs: true
repo: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}"
revision: "${{CF_BRANCH}}"
git: "github"
pickupColor:
title: "extract color from commit message"
stage: clone
image: ubuntu
commands:
- |
export COLOR=$(echo "${CF_COMMIT_MESSAGE}" | awk -F":" '{print $1}')
cf_export COLOR=$COLOR
build:
title: "Building Docker image"
type: "build"
image_name: "aperturesci/rollouts-demo"
working_directory: "${{clone}}"
tag: "${{CF_SHORT_REVISION}}"
dockerfile: "Dockerfile"
registry: dockerhub
stage: "build"
platform: 'linux/amd64,linux/arm64'
buildx: true
build_arguments:
- COLOR=${{COLOR}}
- LATENCY=0
- ERROR_RATE=0
metadata:
set:
- color: ${{COLOR}}
on_success:
annotations:
set:
- annotations:
- sha: ${{CF_SHORT_REVISION}}
- color: ${{COLOR}}
display: color
metadata_tasks:
description: "Tasks to get credentials for signing images"
type: parallel
stage: "metadata"
when:
condition:
all:
alert: "'${{QUICK_EXECUTION}}' == 'false'"
steps:
prepcosign:
title: Fetch Cosign and Docker Keys
image: ubuntu
stage: metadata
commands:
- mkdir -p ${{CF_VOLUME_PATH}}/.docker
- echo ${{DOCKERCONFIG}} | base64 -d > ${{CF_VOLUME_PATH}}/.docker/config.json
obtain_id_token:
stage: "metadata"
title: Obtain ID Token
type: obtain-oidc-id-token:1.2.3
arguments:
AUDIENCE: 'sigstore'
reporting:
title: Reporting
type: parallel
stage: "metadata"
fail_fast: false
when:
condition:
all:
alert: "'${{QUICK_EXECUTION}}' == 'false'"
steps:
enrich-image:
stage: build
title: Report image to Codefresh CD
type: codefresh-report-image:1.0.11
working_directory: /code
fail_fast: false
arguments:
CF_API_KEY: ${{CF_API_KEY}}
CF_IMAGE: "docker.io/aperturesci/rollouts-demo:${{CF_SHORT_REVISION}}"
CF_RUNTIME_NAME: demo
CF_CONTAINER_REGISTRY_INTEGRATION: docker-intg
CF_GITHUB_TOKEN: "${{GITHUB_TOKEN}}"
CF_GIT_PROVIDER: github
CF_GIT_REPO: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}"
CF_GIT_BRANCH: "master"
CF_GIT_REVISION: "${{CF_REVISION}}"
CF_JIRA_INTEGRATION: jira-intg
CF_JIRA_MESSAGE: "${{CF_COMMIT_MESSAGE_ESCAPED}}"
CF_JIRA_PROJECT_PREFIX: AP
# when:
# condition:
# all:
# alert: "'${{SLACK_ALERT}}' == 'true'"
# cosign:
# title: Cosign Image
# image: bitnamilegacy/cosign:2.5.3
# stage: metadata
# fail_fast: false
# commands:
# - cp -r ${{CF_VOLUME_PATH}}/.docker /
# - cosign sign --key ${{CF_VOLUME_PATH}}/cosign.key aperturesci/rollouts-demo:${{CF_SHORT_REVISION}} -a CICD=Codefresh --yes
# - rm ${{CF_VOLUME_PATH}}/cosign.key
cosign:
title: Keyless Image cosign
image: bitnamilegacy/cosign:2.5.3
fail_fast: false
commands:
- |
export SIGSTORE_ID_TOKEN=$ID_TOKEN
cp -r ${{CF_VOLUME_PATH}}/.docker /
cosign sign --oidc-issuer "https://oidc.codefresh.io" --yes=true aperturesci/rollouts-demo:${{CF_SHORT_REVISION}} -a CICD=Codefresh --yes
rm -rf ${{CF_VOLUME_PATH}}/.docker
JiraCommentCreate:
title: "Add Jira Comment"
type: jira-issue-manager:1.0.11
fail_fast: false
arguments:
JIRA_API_KEY: ${{JIRA_API_KEY}}
JIRA_BASE_URL: ${{JIRA_URL}}
JIRA_USERNAME: ${{JIRA_USER}}
JIRA_ISSUE_SOURCE_FIELD: "AP-57453"
ACTION: "comment_create"
COMMENT_BODY: "Color update to ${{COLOR}} in Codefresh build [${{CF_BUILD_ID}}|${{CF_BUILD_URL}}] finished in Codefresh."
#
# DEV
#
# approve_dev:
# stage: dev
# type: pending-approval
# timeout:
# timeUnit: minutes
# duration: 3
# finalState: approved
update_dev:
title: Update dev env
type: codefresh-run:1.5.3
stage: dev
arguments:
PIPELINE_ID: DevOps/color_update_manifest
VARIABLE:
- ENV=dev
- TAG=${{CF_SHORT_REVISION}}
sync_dev:
type: gitops-argocd-sync:1.5.0
title: Sync ArgoCD app in DEV and wait
stage: dev
arguments:
# IMAGE_TAG: "1.5.0"
LOG_LEVEL: debug
RUNTIME: demo
APPLICATION: color-dev
APP_NAMESPACE: demo
#
# QA
#
approve_qa:
stage: qa
type: pending-approval
timeout:
timeUnit: minutes
duration: 5
finalState: approved
update_qa:
title: Update qa env
type: codefresh-run:1.5.3
stage: qa
arguments:
PIPELINE_ID: DevOps/color_update_manifest
VARIABLE:
- ENV=qa
- TAG=${{CF_SHORT_REVISION}}
# sync_qa:
# type: gitops-argocd-sync:1.5.0
# title: Sync ArgoCD app in QA and wait
# stage: qa
# arguments:
# IMAGE_TAG: "1.5.0"
# RUNTIME: demo
# APPLICATION: color-qa
#
# Prod US West and East
#
approve_us:
stage: us
type: pending-approval
timeout:
timeUnit: minutes
duration: 5
finalState: approved
east:
title: Update east env
type: codefresh-run:1.5.3
stage: us
arguments:
PIPELINE_ID: DevOps/color_update_manifest
VARIABLE:
- ENV=east
- TAG=${{CF_SHORT_REVISION}}
update_west:
title: Update west env
type: codefresh-run:1.5.3
stage: us
arguments:
PIPELINE_ID: DevOps/color_update_manifest
VARIABLE:
- ENV=west
- TAG=${{CF_SHORT_REVISION}}
# sync_us:
# type: parallel
# stage: us
# steps:
# sync_east:
# title: Sync ArgoCD app in US East and wait
# type: gitops-argocd-sync:1.5.0
# arguments:
# IMAGE_TAG: "1.5.0"
# RUNTIME: high
# APPLICATION: color-east
#
# sync_west:
# title: Sync ArgoCD app in US West and wait
# type: gitops-argocd-sync:1.5.0
# arguments:
# IMAGE_TAG: "1.5.0"
# RUNTIME: high
# APPLICATION: color-west