-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
313 lines (240 loc) · 10.6 KB
/
.gitlab-ci.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
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
---
variables:
MY_PROJECT_ID: "57560288"
# GIT_SYNC_URL: "https://$GITHUB_USERNAME_ROBOT:$GITHUB_TOKEN_ROBOT@github.com/NoFussComputing/centurion_erp.git"
# # Docker Build / Publish
# DOCKER_IMAGE_BUILD_TARGET_PLATFORMS: "linux/amd64,linux/arm64"
# DOCKER_IMAGE_BUILD_NAME: centurion-erp
# DOCKER_IMAGE_BUILD_REGISTRY: $CI_REGISTRY_IMAGE
# DOCKER_IMAGE_BUILD_TAG: $CI_COMMIT_SHA
# # Docker Publish
# DOCKER_IMAGE_PUBLISH_NAME: centurion-erp
# DOCKER_IMAGE_PUBLISH_REGISTRY: docker.io/nofusscomputing
# DOCKER_IMAGE_PUBLISH_URL: https://hub.docker.com/r/nofusscomputing/$DOCKER_IMAGE_PUBLISH_NAME
# # Extra release commands
# MY_COMMAND: ./.gitlab/additional_actions_bump.sh
# Docs NFC
PAGES_ENVIRONMENT_PATH: projects/centurion_erp/
# RELEASE_ADDITIONAL_ACTIONS_BUMP: ./.gitlab/additional_actions_bump.sh
include:
# - local: .gitlab/pytest.gitlab-ci.yml
# - local: .gitlab/unit-test.gitlab-ci.yml
- project: nofusscomputing/projects/gitlab-ci
ref: development
file:
- .gitlab-ci_common.yaml
# - template/automagic.gitlab-ci.yaml
- automation/.gitlab-ci-ansible.yaml
- template/mkdocs-documentation.gitlab-ci.yaml
- lint/ansible.gitlab-ci.yaml
# Update Git Submodules:
# extends: .ansible_playbook_git_submodule
# Docker Container:
# extends: .build_docker_container
# resource_group: build
# needs: []
# script:
# - update-binfmts --display
# - |
# echo "[DEBUG] building multiarch/specified arch image";
# docker buildx build --platform=$DOCKER_IMAGE_BUILD_TARGET_PLATFORMS . \
# --label org.opencontainers.image.created="$(date '+%Y-%m-%d %H:%M:%S%:z')" \
# --label org.opencontainers.image.documentation="$CI_PROJECT_URL" \
# --label org.opencontainers.image.source="$CI_PROJECT_URL" \
# --label org.opencontainers.image.revision="$CI_COMMIT_SHA" \
# --push \
# --build-arg CI_PROJECT_URL=$CI_PROJECT_URL \
# --build-arg CI_COMMIT_SHA=$CI_COMMIT_SHA \
# --build-arg CI_COMMIT_TAG=$CI_COMMIT_TAG \
# --file $DOCKER_DOCKERFILE \
# --tag $DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG;
# docker buildx imagetools inspect $DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG;
# # during docker multi platform build there are >=3 additional unknown images added to gitlab container registry. cleanup
# DOCKER_MULTI_ARCH_IMAGES=$(docker buildx imagetools inspect "$DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG" --format "{{ range .Manifest.Manifests }}{{ if ne (print .Platform) \"&{unknown unknown [] }\" }}$DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG@{{ println .Digest }}{{end}} {{end}}");
# docker buildx imagetools create $DOCKER_MULTI_ARCH_IMAGES --tag $DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG;
# docker buildx imagetools inspect $DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG;
# rules: # rules manually synced from docker/publish.gitlab-ci.yaml removing git tag
# # - if: # condition_master_branch_push
# # $CI_COMMIT_BRANCH == "master" &&
# # $CI_PIPELINE_SOURCE == "push"
# # exists:
# # - '{dockerfile,dockerfile.j2}'
# # when: always
# - if:
# $CI_COMMIT_AUTHOR =='nfc_bot <helpdesk@nofusscomputing.com>'
# &&
# $CI_COMMIT_BRANCH == "development"
# when: never
# - if: # condition_not_master_or_dev_push
# $CI_COMMIT_BRANCH != "master" &&
# $CI_COMMIT_BRANCH != "development" &&
# $CI_PIPELINE_SOURCE == "push"
# exists:
# - '{dockerfile,dockerfile.j2}'
# changes:
# paths:
# - '{dockerfile,dockerfile.j2,includes/**/*}'
# compare_to: 'development'
# when: always
# - if: $CI_COMMIT_TAG
# exists:
# - '{dockerfile,dockerfile.j2}'
# when: always
# - if: # condition_dev_branch_push
# (
# $CI_COMMIT_BRANCH == "development"
# ||
# $CI_COMMIT_BRANCH == "master"
# )
# &&
# $CI_PIPELINE_SOURCE == "push"
# exists:
# - '{dockerfile,dockerfile.j2}'
# allow_failure: true
# when: on_success
# - when: never
# .gitlab_release:
# stage: release
# image: registry.gitlab.com/gitlab-org/release-cli:latest
# before_script:
# - if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=gitlab-ci; else ROOT_DIR=$JOB_ROOT_DIR ; fi
# - echo "[DEBUG] ROOT_DIR[$ROOT_DIR]"
# - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME"
# - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests"
# - apk update
# - apk add git curl
# - apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
# - python -m ensurepip && ln -sf pip3 /usr/bin/pip
# - pip install --upgrade pip
# - pip install -r $ROOT_DIR/gitlab_release/requirements.txt
# # - pip install $ROOT_DIR/gitlab_release/python-module/cz_nfc/.
# - pip install commitizen --force
# - 'CLONE_URL="https://gitlab-ci-token:$GIT_COMMIT_TOKEN@gitlab.com/$CI_PROJECT_PATH.git"'
# - echo "[DEBUG] CLONE_URL[$CLONE_URL]"
# - git clone -b development $CLONE_URL repo
# - cd repo
# - git branch
# - git config --global user.email "helpdesk@nofusscomputing.com"
# - git config --global user.name "nfc_bot"
# - git push --set-upstream origin development
# - RELEASE_VERSION_CURRENT=$(cz version --project)
# script:
# - if [ "$CI_COMMIT_BRANCH" == "development" ] ; then RELEASE_CHANGELOG=$(cz bump --changelog --changelog-to-stdout --prerelease beta); else RELEASE_CHANGELOG=$(cz bump --changelog --changelog-to-stdout); fi
# - RELEASE_VERSION_NEW=$(cz version --project)
# - RELEASE_TAG=$RELEASE_VERSION_NEW
# - echo "[DEBUG] RELEASE_VERSION_CURRENT[$RELEASE_VERSION_CURRENT]"
# - echo "[DEBUG] RELEASE_CHANGELOG[$RELEASE_CHANGELOG]"
# - echo "[DEBUG] RELEASE_VERSION_NEW[$RELEASE_VERSION_NEW]"
# - echo "[DEBUG] RELEASE_TAG[$RELEASE_TAG]"
# - RELEASE_TAG_SHA1=$(git log -n1 --format=format:"%H")
# - echo "[DEBUG] RELEASE_TAG_SHA1[$RELEASE_TAG_SHA1]"
# - |
# if [ "0$RELEASE_VERSION_CURRENT" == "0$RELEASE_VERSION_NEW" ]; then
# echo "[DEBUG] not running extra actions, no new version";
# else
# echo "[DEBUG] Creating new Version Label";
# echo "----------------------------";
# echo ${MY_COMMAND};
# echo "----------------------------";
# cat ${MY_COMMAND};
# echo "----------------------------";
# ${MY_COMMAND};
# echo "----------------------------";
# fi
# - if [ "0$RELEASE_VERSION_CURRENT" == "0$RELEASE_VERSION_NEW" ]; then echo "[DEBUG] No tag to delete, version was not bumped"; else git tag -d $RELEASE_TAG; fi
# - if [ "0$RELEASE_VERSION_CURRENT" == "0$RELEASE_VERSION_NEW" ]; then echo "[DEBUG] No push will be conducted, version was not bumped"; else git push; fi
# - if [ "0$RELEASE_VERSION_CURRENT" == "0$RELEASE_VERSION_NEW" ]; then echo "[DEBUG] No release will be created, version was not bumped"; else release-cli create --name "Release $RELEASE_TAG" --tag-name "$RELEASE_TAG" --tag-message "$RELEASE_CHANGELOG" --ref "$RELEASE_TAG_SHA1" --description "$RELEASE_CHANGELOG"; fi
# - if [ "$CI_COMMIT_BRANCH" == "master" ] ; then git checkout master; fi
# - if [ "$CI_COMMIT_BRANCH" == "master" ] ; then git push --set-upstream origin master; fi
# - if [ "$CI_COMMIT_BRANCH" == "master" ] ; then git merge --no-ff development; fi
# - if [ "$CI_COMMIT_BRANCH" == "master" ] ; then git push origin master; fi
# after_script:
# - rm -Rf repo
# rules:
# - if: '$JOB_STOP_GITLAB_RELEASE'
# when: never
# - if: "$CI_COMMIT_AUTHOR =='nfc_bot <helpdesk@nofusscomputing.com>'"
# when: never
# - if: # condition_master_branch_push
# $CI_COMMIT_BRANCH == "master" &&
# $CI_PIPELINE_SOURCE == "push"
# allow_failure: false
# when: on_success
# - if: # condition_dev_branch_push
# $CI_COMMIT_BRANCH == "development" &&
# $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
# # for testing
# # - if: '$CI_COMMIT_BRANCH != "master"'
# # when: always
# # allow_failure: true
# - when: never
# #
# # Release
# #
# Gitlab Release:
# extends:
# - .gitlab_release
# Docker.Hub.Branch.Publish:
# extends: .publish-docker-hub
# needs: [ "Docker Container" ]
# resource_group: build
# rules: # rules manually synced from docker/publish.gitlab-ci.yaml removing git tag
# # - if: # condition_master_branch_push
# # $CI_COMMIT_BRANCH == "master" &&
# # $CI_PIPELINE_SOURCE == "push"
# # exists:
# # - '{dockerfile,dockerfile.j2}'
# # when: always
# - if:
# $CI_COMMIT_AUTHOR =='nfc_bot <helpdesk@nofusscomputing.com>'
# &&
# $CI_COMMIT_BRANCH == "development"
# when: never
# - if: $CI_COMMIT_TAG
# exists:
# - '{dockerfile,dockerfile.j2}'
# when: always
# - if: # condition_dev_branch_push
# $CI_COMMIT_BRANCH == "development" &&
# $CI_PIPELINE_SOURCE == "push"
# exists:
# - '{dockerfile,dockerfile.j2}'
# allow_failure: true
# when: on_success
# - when: never
# Github (Push --mirror):
# extends:
# - .git_push_mirror
# needs: []
# rules:
# - if: '$JOB_STOP_GIT_PUSH_MIRROR'
# when: never
# - if: $GIT_SYNC_URL == null
# when: never
# - if: # condition_master_or_dev_push
# $CI_COMMIT_BRANCH
# &&
# $CI_PIPELINE_SOURCE == "push"
# when: always
# - when: never
Website.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/infrastructure/website
environment:
url: https://nofusscomputing.com/$PAGES_ENVIRONMENT_PATH
name: Documentation
rules:
- if: # condition_dev_branch_push
$CI_COMMIT_BRANCH == "development" &&
$CI_PIPELINE_SOURCE == "push"
exists:
- '{docs/**,pages/**}/*.md'
changes:
paths:
- '{docs/**,pages/**}/*.md'
compare_to: 'master'
when: always
- when: never