-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
95 lines (90 loc) · 2.32 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
85
86
87
88
89
90
91
92
93
94
95
stages:
- test
- build
- deploy
test:
stage: test
image: node:lts
before_script:
- yarn install
script:
- yarn lint
- yarn test --passWithNoTests
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
except:
- schedules
audit:
stage: test
image: node:lts
before_script:
- yarn install
script:
- yarn audit
allow_failure: true
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
license:
stage: test
image:
name: fsfe/reuse
entrypoint: [""]
script:
- reuse lint
allow_failure: true
build_image:
image: docker:19.03.1
stage: build
rules:
- if: '$CI_COMMIT_REF_NAME == "master"'
when: on_success
services:
- docker:19.03.1-dind
variables:
BUILD_IMAGE_TAG: $CI_REGISTRY_IMAGE:build-$CI_COMMIT_REF_SLUG
GCR_IMAGE_TAG: $GCR_REGISTRY/$GCR_PROJECT_ID/editorial-chatbot:git-$CI_COMMIT_SHORT_SHA
GITLAB_IMAGE_TAG: $CI_REGISTRY_IMAGE:git-$CI_COMMIT_SHORT_SHA
DOCKER_BUILDKIT: 1
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker login -u _json_key --password-stdin https://$GCR_REGISTRY < "$GOOGLE_SERVICE_ACCOUNT_CREDENTIALS"
script:
- |
docker build -t $BUILD_IMAGE_TAG -f Dockerfile.production \
--cache-from node:12-slim \
--cache-from $CI_REGISTRY_IMAGE:build-master \
--cache-from $BUILD_IMAGE_TAG \
--build-arg BUILDKIT_INLINE_CACHE=1 \
.
- docker push $BUILD_IMAGE_TAG
- docker tag $BUILD_IMAGE_TAG $GITLAB_IMAGE_TAG
- docker push $GITLAB_IMAGE_TAG
- docker tag $BUILD_IMAGE_TAG $GCR_IMAGE_TAG
- docker push $GCR_IMAGE_TAG
deploy:
image: dtzar/helm-kubectl:3.2.1
stage: deploy
rules:
- if: '$CI_COMMIT_REF_NAME == "master"'
when: manual
environment:
name: master
kubernetes:
namespace: factchecklab
variables:
GCR_IMAGE: $GCR_REGISTRY/$GCR_PROJECT_ID/editorial-chatbot
before_script:
- helm dep build chart
script:
- |
helm upgrade -n "$KUBE_NAMESPACE" "$HELM_RELEASE_NAME" chart \
--install \
--atomic \
--set image.tag="git-$CI_COMMIT_SHORT_SHA" \
--set image.repository="$GCR_IMAGE" \
--values ${HELM_UPGRADE_VALUES_FILE:-/dev/null} \
--values ${HELM_RELEASE_UPGRADE_VALUES_FILE:-/dev/null}