-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
39 lines (33 loc) · 1.31 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
image: docker:latest
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay
before_script:
# Install CA certs, openssl to https downloads, python for gcloud sdk
- apk add --update make ca-certificates openssl python
- update-ca-certificates
# Write our GCP service account private key into a file
- echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json
# Download and install Google Cloud SDK
- wget https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz
- tar zxvf google-cloud-sdk.tar.gz && ./google-cloud-sdk/install.sh --usage-reporting=false --path-update=true
- google-cloud-sdk/bin/gcloud --quiet components update
- google-cloud-sdk/bin/gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json
- docker login -u _json_key --password-stdin https://gcr.io < ${HOME}/gcloud-service-key.json
stages:
- publish
publish-master:
stage: publish
script:
- docker build --pull -t "gcr.io/$GCLOUD_PROJECT_ID/$CI_PROJECT_NAME" .
- docker push "gcr.io/$GCLOUD_PROJECT_ID/$CI_PROJECT_NAME:latest"
only:
- master
publish-branch:
stage: publish
script:
- docker build --pull -t "gcr.io/$GCLOUD_PROJECT_ID/$CI_PROJECT_NAME:$CI_COMMIT_REF_SLUG" .
- docker push "gcr.io/$GCLOUD_PROJECT_ID/$CI_PROJECT_NAME:$CI_COMMIT_REF_SLUG"
except:
- master