-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
81 lines (73 loc) · 3.06 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
stages:
- test
- deploy
image: eu.gcr.io/speedy-lattice-334/chromium-xvfb:0.1.0
cache:
paths:
- node_modules/
variables:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
CYPRESS_INSTALL_BINARY: 0
CHROMIUM_BIN: /usr/bin/chromium-browser
services:
- name: docker:dind
entrypoint: ['env', '-u', 'DOCKER_HOST']
command: ['dockerd-entrypoint.sh']
before_script:
- apt-get update
- apt-get -qq -y install wget #install wget
- wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
- source $HOME/.bashrc
- export NVM_DIR="$HOME/.nvm" && . "$NVM_DIR/nvm.sh" --no-use #load nvm
- eval "[ -f .nvmrc ] && nvm install || nvm install stable" #install node
- nvm install 12.20.1
- nvm use 12.20.1
tests:
stage: test
tags:
- frontend
- docker
script:
- npm install --silent
- npm run build
- npm run test -- --coverage --watchAll=false
- git fetch origin master
- git checkout master
- git checkout -B "$CI_BUILD_REF_NAME"
artifacts:
name: '${CI_PROJECT_NAME}_${CI_BUILD_ID}'
paths:
- build/
- coverage/
- junitxml_report/
expire_in: 1 hour
deploy_to_testing:
only:
- master
before_script:
- apk add --update --no-cache curl py-pip jq
- apk add --update make ca-certificates openssl
- update-ca-certificates
- source $CI_PROJECT_DIR/gcloud.sh
# Download and install Google Cloud SDK
- wget https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz
- tar zxf google-cloud-sdk.tar.gz && ./google-cloud-sdk/install.sh --usage-reporting=false --path-update=true
# Instead of writing our GCP service account private key into a file, supply it as env variable
- google-cloud-sdk/bin/gcloud auth activate-service-account --key-file $GCLOUD_SERVICE_ACCOUNT
- google-cloud-sdk/bin/gcloud config set project sghi-307909
- docker login -u _json_key --password-stdin https://eu.gcr.io < $GCLOUD_SERVICE_ACCOUNT
- export CLOUDSDK_CORE_PROJECT=sghi-307909
image: docker:dind
stage: deploy
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ''
resource_group: staging # control deploy concurrency
script:
- docker build -q --build-arg CI_JOB_TOKEN=$CI_JOB_TOKEN -f $CI_PROJECT_DIR/Dockerfile . -t eu.gcr.io/sghi-307909/sghi-testing:$(echo $CI_COMMIT_SHA | cut -c1-8)
- google-cloud-sdk/bin/gcloud auth configure-docker
- docker -- push eu.gcr.io/sghi-307909/sghi-testing:$(echo $CI_COMMIT_SHA | cut -c1-8)
- google-cloud-sdk/bin/gcloud run deploy sghi-testing --image eu.gcr.io/sghi-307909/sghi-testing:$(echo $CI_COMMIT_SHA | cut -c1-8) --region europe-west1 --platform managed --allow-unauthenticated
- google-cloud-sdk/bin/gcloud run services add-iam-policy-binding --platform managed --region=europe-west1 --member=allUsers --role=roles/run.invoker sghi-testing --quiet
tags:
- healthcloud-multi