forked from gadiener/ci-templates
-
Notifications
You must be signed in to change notification settings - Fork 5
/
endpoint.yml
62 lines (52 loc) · 1.5 KB
/
endpoint.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
.endpoint:deploy:
image: europe-west1-docker.pkg.dev/jobtome-platform/public/ci-image-gcp:v1.6.0
stage: deploy
script:
- &connection |
# CLUSTER CONNECTION PHASE
for var in "GOOGLE_KEY" "GOOGLE_PROJECT"; do
if [ -z "${!var}" ]; then
echo
echo "-> [WARNING] Missing '${var}' variable!"
echo
exit 1
fi
done
echo "${GOOGLE_KEY}" > /tmp/key.json
gcloud config set project ${GOOGLE_PROJECT}
echo "Google project '${GOOGLE_PROJECT}' configured"
gcloud auth activate-service-account --key-file ${GOOGLE_KEY}
- |
# DEPLOY PHASE
if [ -z "${ENDPOINT_FILE}" ]; then
ENDPOINT_FILE=endpoint.yaml
fi
echo
echo "-> Deploying endpoint from '${ENDPOINT_FILE}' with tag '${CI_COMMIT_TAG}'"
echo
gcloud endpoints services deploy ${ENDPOINT_FILE}
test:endpoint:production:
image: europe-west1-docker.pkg.dev/jobtome-platform/public/ci-image-gcp:v1.6.0
stage: test
script:
- *connection
- |
# TEST PHASE
if [ -z "${ENDPOINT_FILE}" ]; then
ENDPOINT_FILE=endpoint.yaml
fi
echo
echo "-> Testing endpoint from '${ENDPOINT_FILE}'"
echo
gcloud endpoints services deploy ${ENDPOINT_FILE} --validate-only
deploy:endpoint:production:
extends: .endpoint:deploy
variables:
ENVIRONMENT: production
only:
- /^v.+$/i
except:
- branches
environment:
name: ${ENVIRONMENT}
url: https://${DOMAIN}