-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
101 lines (91 loc) · 2.33 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
image: node:latest
stages:
- lint
- build
- test
- deploy
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
default:
cache:
key:
prefix: $CI_COMMIT_REF_NAME
files:
- server/package-lock.json
- client/package-lock.json
paths:
- server/.npm/
- client/.npm
before_script:
- cd server && npm ci --cache .npm --prefer-offline && cd ../client && npm ci --cache .npm --prefer-offline && cd ..
lint-server:
stage: lint
script:
- cd server && ./node_modules/eslint/bin/eslint.js --ext js,mjs,cjs .
allow_failure: false
lint-client:
stage: lint
script:
- cd client && ./node_modules/eslint/bin/eslint.js --ext js,jsx,mjs,cjs .
allow_failure: false
test-server:
stage: test
script:
- npm install jest
- cd server
- npm run test
allow_failure: true
build-frontend:
stage: build
cache:
key:
prefix: "frontend"
files:
- "client/package-lock.json"
paths:
- "client/node_modules/"
script:
- cd client && npm install && CI=false npm run build
artifacts:
expire_in: 1 days
when: on_success
paths:
- client/build
- client/node_modules
build-backend:
stage: build
cache:
key:
prefix: "backend"
files:
- "server/package-lock.json"
paths:
- "server/node_modules/"
script:
- cd server && npm install
artifacts:
expire_in: 1 days
when: on_success
paths:
- server/node_modules
deploy:
stage: deploy
image: mcr.microsoft.com/azure-cli
dependencies:
- build-frontend
- build-backend
only:
- main
- dev
before_script:
- apk update
- apk add zip
- "az login --allow-no-subscriptions --service-principal -u $AZ_SP_ID -p $AZ_SP_SECRET --tenant $AZ_TENANT"
script:
- zip -r deploy.zip client/build server ./package.json
- "az webapp config appsettings set --resource-group $RESOURCE_GROUP_NAME --name $APP_NAME --settings WEBSITE_RUN_FROM_PACKAGE=$WEBSITE_RUN_FROM_PACKAGE"
- "az webapp config appsettings set --resource-group $RESOURCE_GROUP_NAME --name $APP_NAME --settings ATLAS_URI=$ATLAS_URI"
- "az webapp deployment source config-zip --resource-group $RESOURCE_GROUP_NAME --name $APP_NAME --src deploy.zip"