-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.gitlab-ci.yml
102 lines (94 loc) · 2.46 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
image: docker:git
services:
- docker:dind
stages:
- build_image
- tag_latest
before_script:
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_JOB_TOKEN}" "${CI_REGISTRY}"
###
## BUILD IMAGE
#
# Default branches (master/dev)
build_image.default:
stage: build_image
script:
- docker build --pull
--build-arg BUILD_NAME="${CI_PROJECT_NAME}"
--build-arg BUILD_DATE="$(date '+%FT%T.%s%z')"
--build-arg BUILD_VCSREF="${CI_COMMIT_SHA:0:8}"
-t "${CI_REGISTRY_IMAGE}:branch-${CI_COMMIT_REF_NAME}" .
- docker push "${CI_REGISTRY_IMAGE}:branch-${CI_COMMIT_REF_NAME}"
only:
- master
- dev
except:
- tags
tags:
- tractor
# Issue branches (^[0-9]+-.*])
# Strip branch name branch ID
build_image.feature:
stage: build_image
script:
- docker build --pull
--build-arg BUILD_NAME="${CI_PROJECT_NAME}"
--build-arg BUILD_DATE="$(date '+%FT%T.%s%z')"
--build-arg BUILD_VCSREF="${CI_COMMIT_SHA:0:8}"
-t "${CI_REGISTRY_IMAGE}:branch-${CI_COMMIT_REF_NAME%%-*}" .
- docker push "${CI_REGISTRY_IMAGE}:branch-${CI_COMMIT_REF_NAME%%-*}"
only:
- /^[0-9]+-.*$/
except:
- tags
tags:
- tractor
# Non Standard branches (^[a-zA-Z]+.*)
# Strip branch name to 128 char max
build_image.nonstd:
stage: build_image
script:
- docker build --pull
--build-arg BUILD_NAME="${CI_PROJECT_NAME}"
--build-arg BUILD_DATE="$(date '+%FT%T.%s%z')"
--build-arg BUILD_VCSREF="${CI_COMMIT_SHA:0:8}"
-t "${CI_REGISTRY_IMAGE}:branch-${CI_COMMIT_REF_NAME:0:128}" .
- docker push "${CI_REGISTRY_IMAGE}:branch-${CI_COMMIT_REF_NAME:0:128}"
only:
- /^[a-zA-Z]+.*$/
except:
- master
- dev
- tags
tags:
- tractor
# TAGS
build_image.tag:
stage: build_image
script:
- docker build --pull
--build-arg BUILD_NAME="${CI_PROJECT_NAME}"
--build-arg BUILD_DATE="$(date '+%FT%T.%s%z')"
--build-arg BUILD_VCSREF="${CI_COMMIT_REF_NAME}"
-t "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}" .
- docker push "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}"
only:
- tags
tags:
- tractor
###
## TAG IMAGE
#
# Tag latest on master branch
tag_image.latest:
stage: tag_latest
script:
- docker pull "${CI_REGISTRY_IMAGE}:branch-${CI_COMMIT_REF_NAME}"
- docker tag "${CI_REGISTRY_IMAGE}:branch-${CI_COMMIT_REF_NAME}" "${CI_REGISTRY_IMAGE}:latest"
- docker push "${CI_REGISTRY_IMAGE}:latest"
only:
- master
except:
- tags
tags:
- tractor