forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.yml
287 lines (280 loc) · 9.38 KB
/
config.yml
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
version: 2.1
# this allows to use CircleCI's dynamic configuration feature
setup: true
orbs:
gcp-gcr: circleci/[email protected]
executors:
base-cimg-executor:
docker:
- image: cimg/base:2022.07
python-cimg-executor:
docker:
- image: cimg/python:3.10.4
commands:
asdf_install:
description: "Install tools using ASDF"
parameters:
tools:
type: string
description:
"Newline separated list of tools to install. If empty, will install
everything."
default: ""
cache_name:
type: string
description: "Name of asdf cache"
default: "default"
steps:
- run:
name: Install ASDF
command: |
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.2
printf '\nsource "${HOME}/.asdf/asdf.sh"\n' >> "${BASH_ENV}"
date +%m > ~/month
date +%d > ~/day
# We need to restore ASDF cache after installing, otherwise we will try to clone it to non-empty dir
- restore_cache:
name: Restore ASDF cache
keys:
- grafana-asdf-cache-v7-{{ checksum "~/month" }}-<<
parameters.cache_name >>-{{ checksum ".tool-versions" }}
- grafana-asdf-cache-v7-{{ checksum "~/month" }}-<<
parameters.cache_name >>-
- run:
name: Install ASDF tools
environment:
TOOLS: << parameters.tools >>
command: .circleci/scripts/asdf_install.sh
asdf_save_cache:
parameters:
cache_name:
type: string
description: "Name of asdf cache"
default: "default"
steps:
- save_cache:
name: Save ASDF cache
key:
grafana-asdf-cache-v7-{{ checksum "~/month" }}-<<
parameters.cache_name >>-{{ checksum ".tool-versions" }}
paths:
- ~/.asdf
opsninja_install:
parameters:
branch:
type: string
default: main
description: opsninja branch to install from
fingerprint:
type: string
default: 10:d1:92:4e:2a:55:81:c9:82:c2:74:ce:6d:0e:e8:a8 # fluxninja/cloud R/O
description: What SSH identity to use for accessing opsninja repository
steps:
- add_ssh_keys:
fingerprints:
- << parameters.fingerprint >>
- run:
name: Install opsninja and its dependencies
command: |
# We need R/O access to cloud repository to be able to fetch opsninja library
# FIXME: make "releases" of opsninja library somehow, even as a separate repository
# to limit exposure.
export CLOUD_RO_KEY_FINGERPRINT="<< parameters.fingerprint >>"
export GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_$(echo "${CLOUD_RO_KEY_FINGERPRINT}" | tr -d ':')"
export SSH_AUTH_SOCK=""
# Bust asdf cache as our opsninja version is always 0.0.0
pip uninstall -y opsninja
pip install 'git+ssh://[email protected]/fluxninja/cloud@<< parameters.branch >>#egg=opsninja&subdirectory=ops/apps/opsninja/'
which asdf > /dev/null 2>&1 && asdf reshim
jobs:
release-components:
executor: base-cimg-executor
steps:
- checkout
- asdf_install:
cache_name: release
tools: |-
python
gcloud
- opsninja_install
- run:
name: Schedule release jobs
working_directory: ops/apps/opsninja
command: fn circleci trigger-release --tag << pipeline.git.tag >>
- asdf_save_cache:
cache_name: release
build-push-add-tag:
parameters:
attach-workspace:
type: boolean
description: Boolean for whether or not to attach to an existing workspace
default: false
docker-context:
type: string
description: Path to the directory containing your build context, defaults to .
default: .
dockerfile:
type: string
description: Name of dockerfile to use, defaults to Dockerfile
default: Dockerfile
executor:
type: executor
description: executor to use for this job
default: base-cimg-executor
extra_build_args:
type: string
description: Extra flags to pass to docker build
default: ""
image:
type: string
description: A name for your Docker image
path:
type: string
description: Path to the directory containing your Dockerfile, defaults to .
default: .
remote-docker-version:
type: string
description: Specify the remote docker version
default: 20.10.14
setup-remote-docker:
type: boolean
description: Setup and use CircleCI's remote Docker environment
default: true
tag:
type: string
description: A Docker image tag
default: ${CIRCLE_SHA1:0:8}
target-tag:
type: string
description: Additional image tag applied when job runs on fluxninja_micro_frontends branch
default: latest
use-docker-layer-caching:
type: boolean
description: Setup docker layer caching for optimized build
default: false
workspace-root:
type: string
description: >
Workspace root path that is either an absolute path or a path relative
to the working directory. Defaults to '.' (the working directory)
default: .
executor: <<parameters.executor>>
environment:
DOCKER_BUILDKIT: 1
steps:
- checkout
- when:
condition: <<parameters.setup-remote-docker>>
steps:
- setup_remote_docker:
docker_layer_caching: <<parameters.use-docker-layer-caching>>
version: <<parameters.remote-docker-version>>
- gcp-gcr/gcr-auth
- gcp-gcr/build-image:
attach-workspace: <<parameters.attach-workspace>>
docker-context: <<parameters.docker-context>>
dockerfile: <<parameters.dockerfile>>
extra_build_args: <<parameters.extra_build_args>>
image: <<parameters.image>>
path: <<parameters.path>>
tag: <<parameters.tag>>
workspace-root: <<parameters.workspace-root>>
- gcp-gcr/push-image:
image: <<parameters.image>>
tag: <<parameters.tag>>
- when:
condition:
equal: [fluxninja_micro_frontends, << pipeline.git.branch >>]
steps:
- gcp-gcr/tag-image:
image: <<parameters.image>>
source-tag: <<parameters.tag>>
target-tag: <<parameters.target-tag>>
update-environment:
parameters:
job-root:
type: string
default: "/home/circleci"
description: The root folder of the job where all repositories will be cloned to
manifests-repo:
type: string
default: [email protected]:fluxninja/argo-manifests.git
description: ArgoCD manifests repository to update
manifests-branch:
type: string
default: tests
description: Branch to use when pushing deployment changes
environment-path:
type: string
description: Path to the environment to update
component:
type: string
default: ""
description: Application component to update image and deployment code for
update:
type: string
default: everything
description: Whether to update 'images', 'deployment-code' or 'everything'
executor: python-cimg-executor
steps:
- add_ssh_keys:
fingerprints:
- "f9:49:04:10:b1:77:16:b0:0e:c0:ba:21:0e:9d:fd:40" # argo-manifests R/W
- checkout
- asdf_install:
cache_name: release
tools: |-
python
gcloud
- gcp-gcr/gcr-auth
- opsninja_install
- run:
name: Update application in the deployment
environment:
JOB_ROOT: << parameters.job-root >>
UPDATE: << parameters.update >>
MANIFESTS_BRANCH: << parameters.manifests-branch >>
MANIFESTS_REPO: << parameters.manifests-repo >>
COMPONENT: << parameters.component >>
ENVIRONMENT_PATH: << parameters.environment-path >>
command: .circleci/scripts/update_environment.sh
workflows:
version: 2
build-alpine:
jobs:
- build-push-add-tag:
name: image-build-grafana-alpine
image: cf-fn/grafana
- update-environment:
name: update-demo-environment
filters:
branches:
only:
- fluxninja_micro_frontends
requires:
- image-build-grafana-alpine
environment-path: environments/demo/
component: grafana
update: images
- update-environment:
name: update-nightly-environment
filters:
branches:
only:
- fluxninja_micro_frontends
requires:
- image-build-grafana-alpine
environment-path: environments/nightly/
component: grafana
update: images
release-components:
when:
matches: { value: << pipeline.git.tag >>, pattern: "^releases/.+$" }
jobs:
- release-components:
# both this and workflow's when is needed
filters:
branches:
ignore: /.+/
tags:
only: /releases\/.+/