-
Notifications
You must be signed in to change notification settings - Fork 8
/
codefresh_color.yaml
346 lines (316 loc) · 9.41 KB
/
codefresh_color.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
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
version: "1.0"
stages:
- clone
- build
- metadata
- dev
- qa
- staging
- prod
hooks:
on_fail:
steps:
exec:
type: slack-post-channel:0.0.7
arguments:
SLACK_TOKEN: ${{LR_SLACK_TOKEN}}
SLACK_CHANNEL: topic-codefresh-demo
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"
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
tasks:
type: parallel
stage: "metadata"
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
steps:
enrich-image:
stage: build
title: Report image to Codefresh CD
type: codefresh-report-image:1.0.10
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: gitops
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
# cosign:
# title: Cosign Image
# image: bitnami/cosign:2
# 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: bitnami/cosign:2
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-103"
ACTION: "comment_create"
COMMENT_BODY: "Color update to ${{COLOR}} in Codefresh build [${{CF_BUILD_ID}}|${{CF_BUILD_URL}}] finished in Codefresh."
clone_dev:
title: "Cloning repository for DEV"
type: "git-clone"
git: "github"
repo: aperture-sci/gitops_applications
revision: "main"
depth: 1
exclude_blobs: true
stage: dev
update_dev_manifest:
description: update the image version for Dev
image: codefresh/cli
working_directory: "/codefresh/volume/gitops_applications"
stage: dev
commands:
- yq -i -y '.images[0].newTag="${{CF_SHORT_REVISION}}"' manifests/color/dev/kustomization.yaml
commit_and_push_dev:
title: Commit Dev changes and push
type: git-commit:0.1.4
stage: dev
arguments:
repo: aperture-sci/gitops_applications
git: github-lr
working_directory: /codefresh/volume/gitops_applications
commit_message: "Update image to deploy to ${{COLOR}} (${{CF_SHORT_REVISION}})"
git_user_name: lrochette
git_user_email: [email protected]
allow_empty: true
force_push: true
add:
- manifests/color/dev/kustomization.yaml
# to be sure to get OutOfSync for Argo Notifications
approve_dev:
stage: dev
type: pending-approval
timeout:
timeUnit: minutes
duration: 3
finalState: approved
sync_dev:
type: gitops-argocd-sync:1.4.5
title: Sync ArgoCD app in DEV and wait
stage: dev
arguments:
RUNTIME: gitops
APPLICATION: color-dev
approve_qa:
stage: qa
type: pending-approval
timeout:
timeUnit: minutes
duration: 5
finalState: approved
clone_qa:
title: "Cloning repository for QA"
type: "git-clone"
git: "github"
repo: aperture-sci/gitops_applications
revision: "main"
depth: 1
exclude_blobs: true
stage: qa
update_qa_manifest:
description: update the image version for qa
image: codefresh/cli
working_directory: "/codefresh/volume/gitops_applications"
stage: qa
commands:
- yq -i -y '.images[0].newTag="${{CF_SHORT_REVISION}}"' manifests/color/qa/kustomization.yaml
commit_and_push_qa:
title: Commit changes and push
type: git-commit:0.1.4
stage: qa
arguments:
repo: aperture-sci/gitops_applications
git: github-lr
working_directory: "/codefresh/volume/gitops_applications"
commit_message: "Update image to deploy to ${{COLOR}} (${{CF_SHORT_REVISION}})"
git_user_name: lrochette
git_user_email: [email protected]
allow_empty: true
force_push: true
add:
- manifests/color/qa/kustomization.yaml
sync_qa:
type: gitops-argocd-sync:1.4.5
title: Sync ArgoCD app in QA and wait
stage: qa
arguments:
RUNTIME: gitops
APPLICATION: color-qa
approve_staging:
stage: staging
type: pending-approval
timeout:
timeUnit: minutes
duration: 5
finalState: approved
clone_staging:
title: "Cloning repository for staging"
type: "git-clone"
git: "github"
repo: aperture-sci/gitops_applications
revision: "main"
depth: 1
exclude_blobs: true
stage: staging
update_staging_manifest:
description: update the image version for staging
image: codefresh/cli
working_directory: "/codefresh/volume/gitops_applications"
stage: staging
commands:
- yq -i -y '.images[0].newTag="${{CF_SHORT_REVISION}}"' manifests/color/staging/kustomization.yaml
commit_and_push_staging:
title: Commit changes and push
type: git-commit:0.1.4
stage: staging
arguments:
repo: aperture-sci/gitops_applications
git: github-lr
working_directory: "/codefresh/volume/gitops_applications"
commit_message: "Update image to deploy to ${{COLOR}} (${{CF_SHORT_REVISION}})"
git_user_name: lrochette
git_user_email: [email protected]
allow_empty: true
force_push: true
add:
- manifests/color/staging/kustomization.yaml
sync_staging:
title: Sync ArgoCD app in staging and wait
type: gitops-argocd-sync:1.4.5
stage: staging
arguments:
RUNTIME: gitops
APPLICATION: color-staging
approve_prod:
stage: prod
type: pending-approval
timeout:
timeUnit: minutes
duration: 5
finalState: approved
clone_prod:
title: "Cloning repository for PROD"
type: "git-clone"
git: "github"
repo: aperture-sci/gitops_applications
revision: "main"
depth: 1
exclude_blobs: true
stage: prod
update_prod_manifest:
description: update the image version for prod
image: codefresh/cli
working_directory: "/codefresh/volume/gitops_applications"
stage: prod
commands:
- yq -i -y '.images[0].newTag="${{CF_SHORT_REVISION}}"' manifests/color/prod/kustomization.yaml
commit_and_push_prod:
title: Commit changes and push
type: git-commit:0.1.4
stage: prod
arguments:
repo: aperture-sci/gitops_applications
git: github-lr
working_directory: "/codefresh/volume/gitops_applications"
commit_message: "Update image to deploy to ${{COLOR}} (${{CF_SHORT_REVISION}})"
git_user_name: lrochette
git_user_email: [email protected]
allow_empty: true
force_push: true
add:
- manifests/color/prod/kustomization.yaml
sync_prod:
title: Sync ArgoCD app in prod and wait
type: gitops-argocd-sync:1.4.5
stage: prod
arguments:
RUNTIME: gitops
APPLICATION: color-prod