/
padloc_main_ci.yaml
188 lines (171 loc) · 6.03 KB
/
padloc_main_ci.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
version: "1.0"
#-----------------------------BASE SETTINGS----------------------------------------<
indicators:
# Git integration name to use in all git operations
- &git_integration github-codefresh-personal
# NodeJS image version and tag
- &node_image node:16.13.1
# yq image version and tag
- &yq_image mikefarah/yq:4.40.4
# Git user name for CI commits
- &git_user_name ci-bot
# Git user email for CI commits
- &git_user_email ci-bot@example.com
#----------------------------------------------------------------------------------<
# Pipeline stages in the order of appearing on the build screen
stages:
- "clone"
- "test"
- "build"
- "deploy-dev"
- "approve"
- "deploy-prod"
steps:
#-----------------------------Clone stage-----------------------------------------<
clone:
title: "Cloning repository"
type: "git-clone"
repo: '${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}'
revision: '${{CF_REVISION}}'
git: *git_integration
stage: "clone"
#-----------------------------Tests stage-----------------------------------------<
prepare_tests:
title: "Prepare dependancies"
image: *node_image
working_directory: "${{clone}}"
commands:
- npm ci
stage: "test"
test_stage:
stage: "test"
image: *node_image
working_directory: "${{clone}}"
scale:
test_prettier_check:
title: "Perform prettier check"
commands:
- npm run prettier:check
test_pwa_check:
title: "Perform pwa check"
commands:
- npm run pwa:build
test_webext_check:
title: "Perform web-extension check"
commands:
- npm run web-extension:build
test_srv_dryrun_check:
title: "Perform server dry run check"
commands:
- npm run server:start-dry
test_main_check:
title: "Perform tests"
commands:
- npm run test
#-----------------------------Build stage-----------------------------------------<
build_stage:
stage: "build"
working_directory: "${{clone}}"
type: "build"
tag: "build-cache"
buildkit: true
tags:
- '${{CF_BRANCH}}-${{CF_SHORT_REVISION}}'
metadata:
set:
- qa: passed
scale:
build_server:
title: "Building Server image"
image_name: "${{SERVER_IMAGE}}"
dockerfile: "Dockerfile-server"
build_pwa:
title: "Building PWA image"
image_name: "${{PWA_IMAGE}}"
dockerfile: "Dockerfile-pwa"
#-----------------------------Deploy to Dev stage--------------------------------<
dev_argo_app_source_clone:
stage: "deploy-dev"
title: "Cloning source"
type: "git-clone"
repo: "https://github.com/${{DEV_SOURCE}}.git"
revision: "main"
git: *git_integration
dev_modify_image:
stage: "deploy-dev"
image: *yq_image
working_directory: "${{dev_argo_app_source_clone}}"
commands:
- yq eval '.spec.source.helm.parameters |= map(select(.name == "server.image").value |= "${{SERVER_IMAGE}}:${{CF_BRANCH}}-${{CF_SHORT_REVISION}}")' ${{DEV_APP_FILENAME}} -i
- yq eval '.spec.source.helm.parameters |= map(select(.name == "pwa.image").value |= "${{PWA_IMAGE}}:${{CF_BRANCH}}-${{CF_SHORT_REVISION}}")' ${{DEV_APP_FILENAME}} -i
- cat ${{DEV_APP_FILENAME}}
- cf_export DEV_APP_FOLDER=$(pwd)
commit_and_push_dev:
stage: "deploy-dev"
title: Commit app changes and push
type: git-commit
arguments:
repo: "${{DEV_SOURCE}}"
git: *git_integration
working_directory: "${{DEV_APP_FOLDER}}"
commit_message: update images with tag ${{CF_SHORT_REVISION}}
git_user_name: *git_user_name
git_user_email: *git_user_email
rebase: true
allow_empty: true
link_to_dev_app:
stage: "deploy-dev"
title: Link to the application ingress
working_directory: "${{dev_argo_app_source_clone}}"
image: *yq_image
commands:
- export INGRESS_LINK=$(yq '.spec.source.helm.parameters.[] | select(.name == "ingress.host").value' ${{DEV_APP_FILENAME}})
- cf_export link_to_dev_app_CF_OUTPUT_URL="https://${INGRESS_LINK}"
#-----------------------------Approval stage--------------------------------<
approval:
type: pending-approval
stage: "approve"
description: Approve
title: Update prod with the new image?
arguments:
timeout:
duration: 100
finalState: denied
#-----------------------------Deploy to Prod stage--------------------------------<
prod_argo_app_source_clone:
stage: "deploy-prod"
title: "Cloning source"
type: "git-clone"
repo: "https://github.com/${{PROD_SOURCE}}.git"
revision: "main"
git: *git_integration
prod_modify_image:
stage: "deploy-prod"
image: *yq_image
working_directory: "${{prod_argo_app_source_clone}}"
commands:
- yq eval '.spec.source.helm.parameters |= map(select(.name == "server.image").value |= "${{SERVER_IMAGE}}:${{CF_BRANCH}}-${{CF_SHORT_REVISION}}")' ${{PROD_APP_FILENAME}} -i
- yq eval '.spec.source.helm.parameters |= map(select(.name == "pwa.image").value |= "${{PWA_IMAGE}}:${{CF_BRANCH}}-${{CF_SHORT_REVISION}}")' ${{PROD_APP_FILENAME}} -i
- cat ${{PROD_APP_FILENAME}}
- cf_export PROD_APP_FOLDER=$(pwd)
commit_and_push_prod:
stage: "deploy-prod"
title: Commit app changes and push
type: git-commit
arguments:
repo: "${{PROD_SOURCE}}"
git: *git_integration
working_directory: "${{PROD_APP_FOLDER}}"
commit_message: update images with tag ${{CF_SHORT_REVISION}}
git_user_name: *git_user_name
git_user_email: *git_user_email
rebase: true
allow_empty: true
link_to_prod_app:
stage: "deploy-prod"
title: Link to the application ingress
working_directory: "${{prod_argo_app_source_clone}}"
image: *yq_image
commands:
- export INGRESS_LINK=$(yq '.spec.source.helm.parameters.[] | select(.name == "ingress.host").value' ${{PROD_APP_FILENAME}})
- cf_export link_to_prod_app_CF_OUTPUT_URL="https://${INGRESS_LINK}"