forked from klaro-org/klaro-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
52 lines (46 loc) · 1.35 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
image: node:latest
# Cache modules in between jobs
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
before_script:
- npm ci
stages:
- test
- build
- deploy
lint:
stage: test
script:
- npm run-script lint
build:
stage: deploy
script:
- npm run-script make
artifacts:
paths:
- dist
deploy:
only:
- staging
- tags
stage: deploy
before_script:
- apt-get update -qy
- apt-get install -y rsync
script:
# we deploy tagged commits to the production version and commits in the "staging" branch to the staging environment
- if [ -n "$CI_COMMIT_TAG" ]; then export DIRECTORY=klaro-master; else if [ "$CI_COMMIT_REF_NAME" = "staging" ]; then export DIRECTORY=klaro-staging; else exit 0; fi; fi;
- if [ ! -n "$SERVER_SSH_KEY" ]; then exit 0; fi
- mkdir ~/.ssh
- chmod 700 ~/.ssh
- echo "$SERVER_SSH_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- npm ci
- export CI_APP_VERSION=$CI_COMMIT_TAG APP_VERSION=$CI_COMMIT_SHA
- npm run-script make
- SEPARATE_CSS=1 npm run-script make
- SEPARATE_CSS=1 NO_MINIFY_CSS=1 npm run-script make
- echo "Deploying to $DIRECTORY..."
- if [ -n "$DIRECTORY" ]; then rsync --progress -r -e "ssh -o StrictHostKeyChecking=no -o identityFile=~/.ssh/id_rsa" dist/* $SERVER_USERNAME@$SERVER_IP:/dpkit/$DIRECTORY; fi;