-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
111 lines (98 loc) · 2.41 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
image: golang:1.10-alpine3.7
stages:
- pre-flight
- resolve-dependencies
- compile
- unit-test
- package
- deployment-test
- functional-test
- security-test
- publish
- deploy
variables:
REPOSITORY_NAME: hub.docker.com
GROUP_NAME: dealako
IMAGE_NAME: restapi
APP_PATH: /go/src/github.com/dealako/restapi
before_script:
- mkdir -p ${APP_PATH}
- ln -s $PWD ${APP_PATH}
- mkdir -p ${APP_PATH}/vendor
- cd ${APP_PATH}
- apk add --no-cache --update git make
- go get github.com/golang/dep/cmd/dep
.dockerScripts: &docker_scripts
before_script:
- if [ "${CI_JOB_STAGE}" == "publish" ]; then docker pull ${GROUP_NAME}/${IMAGE_NAME}:${CI_COMMIT_SHA}; fi
after_script:
- docker images -aq ${GROUP_NAME}/${IMAGE_NAME} | xargs docker rmi --force
cache:
key: "$CI_COMMIT_SHA"
untracked: true
paths:
- vendor/
installDependencies:
stage: resolve-dependencies
script:
- cd ${APP_PATH}
- make install-deps
compile:
stage: compile
script:
- cd ${APP_PATH}
- make
artifacts:
expire_in: 1 hr
paths:
- .bin
test:
stage: unit-test
script:
- cd ${APP_PATH}
- make test
artifacts:
expire_in: 1 hr
buildImage:
<<: *docker_scripts
stage: package
dependencies:
- compile
script:
- make docker
- docker build -t ${GROUP_NAME}/${IMAGE_NAME}:${CI_COMMIT_SHA} .
publishTest:
<<: *docker_scripts
stage: publish
script:
- docker tag $GROUP_NAME/${IMAGE_NAME}:$CI_COMMIT_SHA $GROUP_NAME/${IMAGE_NAME}:test
- docker push $GROUP_NAME/${IMAGE_NAME}:test
except:
- tags
publishLatest:
<<: *docker_scripts
stage: publish
script:
- docker tag $GROUP_NAME/${IMAGE_NAME}:$CI_COMMIT_SHA $GROUP_NAME/${IMAGE_NAME}:latest
- docker push $GROUP_NAME/${IMAGE_NAME}:latest
only:
- master@lme/elasticsearch-api
publishTagVersion:
<<: *docker_scripts
stage: publish
script:
- docker tag ${GROUP_NAME}/${IMAGE_NAME}:${CI_COMMIT_SHA} $GROUP_NAME/${IMAGE_NAME}:${CI_COMMIT_REF_NAME}
- docker push ${GROUP_NAME}/${IMAGE_NAME}:${CI_COMMIT_REF_NAME}
only:
- tags@dealako/restapi
publishStableTag:
<<: *docker_scripts
stage: publish
when: manual
variables:
STABLE_TAG_NAME: stable
script:
- docker tag ${GROUP_NAME}/${IMAGE_NAME}:${CI_COMMIT_SHA} ${GROUP_NAME}/${IMAGE_NAME}:${STABLE_TAG_NAME}
- docker push ${GROUP_NAME}/${IMAGE_NAME}:${STABLE_TAG_NAME}
only:
- tags@dealako/restapi