-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
47 lines (41 loc) · 1.25 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
variables:
GOOGLE_APPLICATION_CREDENTIALS: /gcloud-service-key.json
CI_REGISTRY_IMAGE: eu.gcr.io/tfw-server
CI_IMAGE_TAG: ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}
DOCKER_HOST: "tcp://localhost:2375"
image: docker:18
services: [ "eu.gcr.io/tfw-server/dind" ]
.gcr: &gcr
- echo ${GCLOUD_SERVICE_KEY} | base64 -d >${GOOGLE_APPLICATION_CREDENTIALS}
- docker login -u _json_key --password-stdin https://eu.gcr.io < ${GOOGLE_APPLICATION_CREDENTIALS}
stages:
- build
- release
build:
stage: build
before_script: *gcr
variables:
script:
- docker build -t ${CI_IMAGE_TAG}:${CI_COMMIT_SHA} .
- docker push ${CI_IMAGE_TAG}:${CI_COMMIT_SHA}
except:
- tags
release-by-name:
stage: release
before_script: *gcr
script:
- docker pull ${CI_IMAGE_TAG}:${CI_COMMIT_SHA}
- docker tag ${CI_IMAGE_TAG}:${CI_COMMIT_SHA} ${CI_IMAGE_TAG}:${CI_COMMIT_REF_NAME}
- docker push ${CI_IMAGE_TAG}:${CI_COMMIT_REF_NAME}
except:
- master
release-master:
stage: release
before_script: *gcr
script:
# Pull, Tag, Push nginx
- docker pull ${CI_IMAGE_TAG}:${CI_COMMIT_SHA}
- docker tag ${CI_IMAGE_TAG}:${CI_COMMIT_SHA} ${CI_IMAGE_TAG}:latest
- docker push ${CI_IMAGE_TAG}:latest
only:
- master