-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
115 lines (105 loc) · 2.52 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
default:
# custom image from Dockerfile
image: $CI_REGISTRY_IMAGE/ci:latest
stages:
- initialize
- build
- test
- preview:client
- preview:ui
- deploy
cache:
paths:
- node_modules/
- "**/node_modules/"
initialize:
stage: initialize
only:
refs:
- merge_requests
# skip initialize if no change in package.json
changes:
- "**/package.json"
script:
- lerna bootstrap
- firebase hosting:channel:open live --non-interactive
build:client:
stage: build
only:
- merge_requests
cache:
policy: pull
paths:
- node_modules/
script:
- lerna run --scope @varp/client build --stream
artifacts:
name: "$CI_JOB_NAME"
paths:
- packages/client/dist/
test:
stage: test
cache: {}
only:
- merge_requests
script:
- echo test
preview:client:
stage: preview:client
only:
- merge_requests
script:
- firebase hosting:channel:deploy $CI_COMMIT_REF_SLUG --non-interactive --token "$FIREBASE_TOKEN"
- echo "ENVIRONMENT_URL=$(firebase hosting:channel:open $CI_COMMIT_REF_SLUG --non-interactive | awk '{ print tolower($3) }')" >> deploy.env
environment:
name: review/$CI_COMMIT_REF_NAME
url: $ENVIRONMENT_URL
variables:
ENVIRONMENT: staging
artifacts:
reports:
dotenv: deploy.env
# auto done by chromatic
# preview:ui:
# stage: preview:ui
# only:
# - merge_requests
# cache:
# policy: pull
# paths:
# - node_modules/
# script:
# - npx lerna run --scope @varp/ui chromatic --stream
# artifacts:
# name: "$CI_JOB_NAME"
# paths:
# - packages/ui/dist/
deploy_client:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
ENVIRONMENT: production
script:
- export PREV_COMMIT_SLUG=$(git log --pretty='%s' -1 | awk '{ print tolower($3) }' | sed -e "s/^'//" -e "s/'$//")
- firebase hosting:clone varp-ba7a7:$PREV_COMMIT_SLUG varp-ba7a7:live --non-interactive --token "$FIREBASE_TOKEN"
- echo "ENVIRONMENT_URL=$(firebase hosting:channel:open live --non-interactive | awk '{ print tolower($3) }')" >> deploy.env
environment:
name: production
url: $ENVIRONMENT_URL
artifacts:
reports:
dotenv: deploy.env
deploy_functions:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- functions/*
script:
- cd functions
- npm install
- cd ..
- firebase deploy --only functions --non-interactive --token "$FIREBASE_TOKEN"
environment:
name: production-functions