-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
107 lines (100 loc) · 4.59 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
stages:
- environment
- build
- test
- deprovision
.build_image: &build_image
image:
# We recommend using the CERN version of the Kaniko image: gitlab-registry.cern.ch/ci-tools/docker-image-builder
name: gitlab-registry.cern.ch/ci-tools/docker-image-builder
entrypoint: [""]
script:
# This is not the common Authentication config, unknown reason why common config fails
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64)\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context "$CI_PROJECT_DIR/$CONTEXT_DIR" --dockerfile "$CI_PROJECT_DIR/$CONTEXT_DIR/$DOCKERFILE"
--destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${TAG}" $BUILD_ARGS
- echo "Image pushed to ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${TAG}"
environment:
stage: environment
script:
- |
export DATE=$(date -u +%Y.%m.%dT%H-%M-%SZ);
case "$CI_COMMIT_BRANCH" in
v*) export TAG="${CI_COMMIT_BRANCH}-RELEASE-${DATE}" ;;
master) export TAG="${CI_COMMIT_BRANCH}-RELEASE-${DATE}" ;;
*) export TAG="${CI_COMMIT_BRANCH}-${CI_COMMIT_SHORT_SHA}" ;;
esac
- wget --no-check-certificate https://github.com/mikefarah/yq/releases/download/v4.2.0/yq_linux_amd64 -O /yq && chmod +x /yq
- export softwareVersions=$CI_PROJECT_DIR/images/softwareVersions
- export nginxVersion=`/yq e .nginx $softwareVersions`
- export nginxNJSVersion=`/yq e .nginxNJS $softwareVersions`
- export phpVersion=`/yq e .php $softwareVersions`
- export composerVersion=`/yq e .composer $softwareVersions`
- export composerBuilderTag=`/yq e .composerBuilderTag $softwareVersions`
- echo "TAG=$TAG" >> env.env
- echo "nginxVersion=$nginxVersion" >> env.env
- echo "nginxNJSVersion=$nginxNJSVersion" >> env.env
- echo "phpVersion=$phpVersion" >> env.env
- echo "composerVersion=$composerVersion" >> env.env
- echo "composerBuilderTag=$composerBuilderTag" >> env.env
- echo "NAMESPACE=cern-drupal-distribution-ci" >> env.env
- echo "PIPELINE_ID=${RANDOM}" >> env.env
artifacts:
reports:
dotenv: env.env
build-sitebuilder:
<<: *build_image
stage: build
needs: [environment]
variables:
IMAGE_NAME: 'site-builder'
CONTEXT_DIR: 'images'
DOCKERFILE: 'Dockerfile-sitebuilder'
# space-separated list of variables to interpolate in the dockerfile
BUILD_ARGS: '--build-arg COMPOSER_BUILDER_TAG=$composerBuilderTag'
build-composerbuilder:
<<: *build_image
stage: build
needs: [environment]
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- when: manual
allow_failure: true
variables:
IMAGE_NAME: 'composer-builder'
CONTEXT_DIR: 'images'
DOCKERFILE: 'Dockerfile-composerbuilder'
# space-separated list of variables to interpolate in the dockerfile
BUILD_ARGS: '--build-arg PHP_VERSION=$phpVersion --build-arg COMPOSER_VERSION=$composerVersion --build-arg NGINX_VERSION=$nginxVersion --build-arg NJS_VERSION=$nginxNJSVersion'
test-newsite-provision:
stage: test
needs:
- environment
- build-sitebuilder
image: gitlab-registry.cern.ch/paas-tools/openshift-client:4
variables:
SITENAME: 'test-newsite-${PIPELINE_ID}'
script:
# Currently, all we require for all tests is to retrieve envsubst binary since it's not present on https://gitlab.cern.ch/paas-tools/openshift-client
# Can be removed once https://gitlab.cern.ch/paas-tools/openshift-client/-/merge_requests/18#note_5241799 is resolved
- curl -L --silent https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-`uname -s`-`uname -m` -o /usr/local/bin/envsubst && chmod +x /usr/local/bin/envsubst
- ./.gitlab/ci/scripts/test-new-site-creation.sh
test-clonesite-provision:
stage: test
needs:
- environment
- build-sitebuilder
image: gitlab-registry.cern.ch/paas-tools/openshift-client:4
variables:
SITENAME: 'test-clonesite-${PIPELINE_ID}'
script:
# Currently, all we require for all tests is to retrieve envsubst binary since it's not present on https://gitlab.cern.ch/paas-tools/openshift-client
# Can be removed once https://gitlab.cern.ch/paas-tools/openshift-client/-/merge_requests/18#note_5241799 is resolved
- curl -L --silent https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-`uname -s`-`uname -m` -o /usr/local/bin/envsubst && chmod +x /usr/local/bin/envsubst
- ./.gitlab/ci/scripts/test-clone-site-creation.sh
deprovision-test-resources:
stage: deprovision
image: gitlab-registry.cern.ch/paas-tools/openshift-client:4
script:
- ./.gitlab/ci/scripts/deprovision-test-resources.sh