-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
84 lines (76 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
include:
- template: Code-Quality.gitlab-ci.yml
image: node:10-alpine
stages:
- lint
- build
- test
- docker_build_push
- deploy_staging
- deploy_prod
lint:
stage: lint
script:
- npm ci
- npm run lint
build:
stage: build
script:
- npm install rimraf
- npm run build --if-present
cache:
policy: push
paths:
- node_modules/
test:
stage: test
script:
- npm install jest
- npm run test:cov
coverage: '/Statements.*?(\d+(?:\.\d+)?)%/'
docker_build_push:
stage: docker_build_push
image: youdowell/gcloud-dind
services:
- docker:dind
before_script:
- docker info
- gcloud components update
- gcloud auth activate-service-account $GCLOUD_CONTAINER_REGISTRY_SA --key-file=$GCLOUD_CONTAINER_REGISTRY_SA_AUTH
- gcloud auth configure-docker --quiet
script:
- docker build . --file Dockerfile --tag $REGISTRY/devops-test:$CI_COMMIT_SHA
- docker push $REGISTRY/devops-test:$CI_COMMIT_SHA
- docker tag $REGISTRY/devops-test:$CI_COMMIT_SHA $REGISTRY/devops-test
- docker push $REGISTRY/devops-test
- docker tag $REGISTRY/devops-test $REGISTRY/devops-test:$CI_COMMIT_REF_NAME
- docker push $REGISTRY/devops-test:$CI_COMMIT_REF_NAME
deploy_staging:
image: google/cloud-sdk:alpine
stage: deploy_staging
script:
- gcloud components update
- gcloud auth activate-service-account $GCLOUD_SERVICE_ACCOUNT --key-file=$GCLOUD_AUTH
- gcloud config set run/platform managed
- gcloud config set run/region $GCLOUD_REGION
- gcloud run deploy $GCLOUD_APP_NAME --quiet --image $REGISTRY/devops-test:$CI_COMMIT_REF_NAME --allow-unauthenticated --update-env-vars DB_HOST=$DB_HOST,DB_PORT=$DB_PORT,DB_USERNAME=$DB_USERNAME,DB_PASSWORD=$DB_PASSWORD,DB_NAME=$DB_NAME --project $GCLOUD_PROJECT
environment:
name: staging
only:
- master
- tags
deploy_prod:
image: google/cloud-sdk:alpine
stage: deploy_prod
script:
- gcloud components update
- gcloud auth activate-service-account $GCLOUD_SERVICE_ACCOUNT --key-file=$GCLOUD_AUTH
- gcloud config set run/platform managed
- gcloud config set run/region $GCLOUD_REGION
- gcloud run deploy $GCLOUD_APP_NAME --quiet --image $REGISTRY/devops-test:$CI_COMMIT_REF_NAME --allow-unauthenticated --update-env-vars DB_HOST=$DB_HOST,DB_PORT=$DB_PORT,DB_USERNAME=$DB_USERNAME,DB_PASSWORD=$DB_PASSWORD,DB_NAME=$DB_NAME --project $GCLOUD_PROJECT
when: manual
environment:
name: production
only:
- master
- tags