-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
73 lines (59 loc) · 1.95 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
image: docker:latest
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
stages:
- build
.build_template: &build_definition
stage: build
only:
refs:
- branches
- /^v(?:\d+\.)+\d+$/
variables:
- $VARIANT_TAG
- $VARIANT_TAG_WITH_VERSION
- $VARIANT_BUILD_DIR
except:
refs:
- master
before_script:
- date '+%Y-%m-%d %H:%M:%S %z'
# Login to Docker Hub registry
- echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin
# Login to GitLab registry
- echo "${CI_REGISTRY_PASSWORD}" | docker login -u "${CI_REGISTRY_USER}" --password-stdin "${CI_REGISTRY}"
script:
- date '+%Y-%m-%d %H:%M:%S %z'
- docker build
-t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}"
-t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_VERSION}"
-t "${CI_REGISTRY_IMAGE}:${VARIANT_TAG}"
-t "${CI_REGISTRY_IMAGE}:${VARIANT_TAG_WITH_VERSION}"
"${VARIANT_BUILD_DIR}"
- date '+%Y-%m-%d %H:%M:%S %z'
# Push to Docker Hub registry. E.g. 'namespace/my-project:tag'
- docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}"
- docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_VERSION}"
# Push to GitLab registry. E.g. 'registry.gitlab.com/namespace/my-project:tag
- docker push "${CI_REGISTRY_IMAGE}:${VARIANT_TAG}"
- docker push "${CI_REGISTRY_IMAGE}:${VARIANT_TAG_WITH_VERSION}"
after_script:
- date '+%Y-%m-%d %H:%M:%S %z'
# Log out of Docker Hub registry
- docker logout
# Log out of GitLab registry
- docker logout "${CI_REGISTRY}"
build-curl:
<<: *build_definition
variables:
VARIANT_TAG: curl
VARIANT_TAG_WITH_VERSION: curl-$CI_COMMIT_REF_NAME
VARIANT_BUILD_DIR: variants/curl
build-git:
<<: *build_definition
variables:
VARIANT_TAG: git
VARIANT_TAG_WITH_VERSION: git-$CI_COMMIT_REF_NAME
VARIANT_BUILD_DIR: variants/git