-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
57 lines (50 loc) · 1.47 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
image: google/cloud-sdk:alpine
variables:
IMAGE: "eu.gcr.io/ffn-utils/hydrantenmap"
CLOUDSDK_CORE_PROJECT: "ffn-utils"
stages:
- build
- test
- deploy
before_script:
- |
# enable service account
if [[ -f "$GOOGLE_APPLICATION_CREDENTIALS" && -n "$(which gcloud)" ]]; then
gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS
fi
# write env file
cat >.env.local <<EOF
NEXT_PUBLIC_FIREBASE_APIKEY='${NEXT_PUBLIC_FIREBASE_APIKEY}'
NEXT_PUBLIC_MAPBOX_APIKEY='${NEXT_PUBLIC_MAPBOX_APIKEY}'
EOF
build_image:
stage: build
script:
- |
export NEXT_PUBLIC_BUILD_ID=$CI_COMMIT_SHORT_SHA
gcloud builds submit . -t $IMAGE:$CI_COMMIT_SHORT_SHA
only:
- "main"
- "dev"
.deploy_to_cloudrun:
stage: deploy
script:
- |
gcloud run deploy $SERVICE_NAME \
--allow-unauthenticated \
--image $IMAGE:$CI_COMMIT_SHORT_SHA \
--max-instances=2 --region europe-west4 \
"--update-env-vars=^@^NEXT_PUBLIC_BUILD_ID=${CI_COMMIT_SHORT_SHA}@NEXT_PUBLIC_FIREBASE_APIKEY=${NEXT_PUBLIC_FIREBASE_APIKEY}@NEXT_PUBLIC_MAPBOX_APIKEY=${NEXT_PUBLIC_MAPBOX_APIKEY}"
deploy_to_cloudrun_main:
extends: .deploy_to_cloudrun
only:
- "main"
variables:
SERVICE_NAME: "hydrantenmap"
deploy_to_cloudrun_dev:
extends: .deploy_to_cloudrun
only:
- "dev"
variables:
SERVICE_NAME: "hydrantenmap-dev"