-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
executable file
·98 lines (91 loc) · 3.04 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
variables:
BUILD_DIR: './drupal'
# Docker variables.
DOCKER_HOST: tcp://docker:2375
RELEASE_REGISTRY: docker.io
RELEASE_IMAGE: index.docker.io/$RELEASE_USER
# Enable buildkit to use '--from-cache' when 'docker build'.
DOCKER_BUILDKIT: 1
DO_RELEASE:
value: "1"
description: Publish the image to docker, set 0 to not publish.
stages:
- prepare
- build
.build_template:
image: docker:latest
stage: build
services:
- docker:dind
needs:
- env
before_script:
- docker --version
# Pull base image from Docker hub.
- docker pull --quiet $IMAGE_BASE || true
# Login to Gitlab and pull current image if exist.
- echo "$CI_JOB_TOKEN" | docker login registry.gitlab.com --username gitlab-ci-token --password-stdin
- docker pull --quiet $CI_REGISTRY_IMAGE/$IMAGE || true
script:
- echo "Build $IMAGE_VERSION with Drupal:$IMAGE_TAG PHP:$PHP_VERSION Node:$NODE_VERSION"
- apk add --no-cache envsubst
- PHP_VERSION="$PHP_VERSION" envsubst < "./drupal/tests/test_php.py.tpl" > "./drupal/tests/test_php.py"
- NODE_VERSION="$NODE_VERSION" envsubst < "./drupal/tests/test_packages.py.tpl" > "./drupal/tests/test_packages.py"
- DRUPAL_VERSION="$IMAGE_TAG" envsubst < "./drupal/tests/test_drush.py.tpl" > "./drupal/tests/test_drush.py"
- docker build
--tag $CI_REGISTRY_IMAGE/$IMAGE
--tag $RELEASE_IMAGE/$IMAGE
--build-arg IMAGE_VERSION=$IMAGE_VERSION
--build-arg IMAGE_TAG=$IMAGE_TAG
--build-arg PHP_VERSION=$PHP_VERSION
--build-arg NODE_VERSION=$NODE_VERSION
--compress
$BUILD_DIR
- docker images
- docker push --quiet $CI_REGISTRY_IMAGE/$IMAGE
- if [[ -d $BUILD_DIR/tests ]]; then ./.gitlab-ci/run-tests.sh $CI_REGISTRY_IMAGE/$IMAGE; fi;
# Login to Docker hub and push.
- echo "$RELEASE_PASSWORD" | docker login $RELEASE_REGISTRY --username $RELEASE_USER --password-stdin
- docker push --quiet $RELEASE_IMAGE/$IMAGE
artifacts:
reports:
junit: junit.xml
env:
stage: prepare
image: alpine:latest
script:
- echo "Set env variables from dotenv."
artifacts:
reports:
dotenv: VERSION.env
previous:
extends: .build_template
variables:
IMAGE_BASE: drupal:${IMAGE_TAG}-php${PHP_VERSION}
IMAGE: drupal-ci:${CI_COMMIT_BRANCH}-${IMAGE_TAG}
IMAGE_TAG: $DRUPAL_PREVIOUS
PHP_VERSION: $DRUPAL_PREVIOUS_PHP
current:
extends: .build_template
variables:
IMAGE_BASE: drupal:${IMAGE_TAG}-php${PHP_VERSION}
IMAGE: drupal-ci:${CI_COMMIT_BRANCH}-${IMAGE_TAG}
IMAGE_TAG: $DRUPAL_CURRENT
PHP_VERSION: $DRUPAL_CURRENT_PHP
# Enabled only when next version is stable
.next:
extends: .build_template
variables:
IMAGE_BASE: drupal:${IMAGE_TAG}-php${PHP_VERSION}
IMAGE: drupal-ci:${CI_COMMIT_BRANCH}-${IMAGE_TAG}
IMAGE_TAG: $DRUPAL_NEXT
PHP_VERSION: $DRUPAL_NEXT_PHP
chrome-headless:
extends: .build_template
variables:
IMAGE_BASE: debian:bullseye-slim
IMAGE: chrome-headless:${CI_COMMIT_BRANCH}
BUILD_DIR: chrome-headless
IMAGE_TAG: ''
PHP_VERSION: ''
NODE_VERSION: ''