forked from epicmaxco/vuestic-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
115 lines (107 loc) · 3.4 KB
/
config.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
aliases:
- &restore_cache
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- &install_dependencies
name: Install Dependencies
command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
- &save_cache
name: Save Yarn Package Cache
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
docker: &docker
docker:
- image: circleci/node:10.13.0
defaults: &defaults
<<: *docker
parallelism: 1
working_directory: ~/repo
version: 2
jobs:
test:
<<: *defaults
steps:
- checkout
- restore_cache: *restore_cache
- run: *install_dependencies
- save_cache: *save_cache
- run: yarn test:unit
deploy-staging:
<<: *defaults
steps:
- checkout
- run:
name: Add variables
command:
echo "VUE_APP_INCLUDE_DEMOS=true" >> .env.production.local &&
echo "VUE_APP_BUILD_VERSION=true" >> .env.production.local &&
echo "VUE_APP_GOOGLE_MAPS_API_KEY=$GOOGLE_MAPS_API_KEY" >> .env.production.local
- restore_cache: *restore_cache
- run: *install_dependencies
- save_cache: *save_cache
- run: yarn build
- add_ssh_keys:
fingerprints:
- "f8:c0:94:79:68:a2:5e:33:9f:78:bc:ad:ed:86:c6:3c"
- run:
name: Add $SERVER_IP to known_hosts
command: ssh-keyscan -H $SERVER_IP >> ~/.ssh/known_hosts
- run:
name: Deploy to hosting
command: |
tar -czf dist.tar.gz ~/repo/dist -C ~/repo/dist .
scp ~/repo/dist.tar.gz $SERVER_USER@$SERVER_IP:~/tmp
ssh $SERVER_USER@$SERVER_IP /bin/bash << EOF
rm -rf $DEPLOY_PATH/*
tar -xzf ~/tmp/dist.tar.gz -C $DEPLOY_PATH
rm -f ~/tmp/dist.tar.gz
EOF
deploy-production:
<<: *defaults
steps:
- checkout
- run:
name: Add variables
command:
echo "VUE_APP_YANDEX_METRICS_KEY=$YANDEX_METRICS_KEY" >> .env.production.local &&
echo "VUE_APP_DRIFT_KEY=$DRIFT_KEY" >> .env.production.local &&
echo "VUE_APP_GOOGLE_MAPS_API_KEY=$GOOGLE_MAPS_API_KEY" >> .env.production.local &&
echo "VUE_APP_GTM_KEY=$GTM_KEY" >> .env.production.local &&
echo "VUE_APP_ROUTER_MODE_HISTORY=$ROUTER_MODE_HISTORY" >> .env.production.local
- restore_cache: *restore_cache
- run: *install_dependencies
- save_cache: *save_cache
- run: yarn build
- run:
name: Deploy to hosting
command: |
tar -czf dist.tar.gz ~/repo/dist -C ~/repo/dist .
ssh-keyscan -t rsa $SERVER_IP >> ~/.ssh/known_hosts
scp ~/repo/dist.tar.gz $SERVER_USERNAME@$SERVER_IP:~/
ssh $SERVER_USERNAME@$SERVER_IP << EOF
mkdir -p tmp
rm -rf $PRODUCTION_DEPLOY_PATH/*
tar -xzf ~/dist.tar.gz -C $PRODUCTION_DEPLOY_PATH
rm -rf ~/dist.tar.gz ~/tmp
EOF
workflows:
version: 2
build-and-deploy:
jobs:
- test
- deploy-staging:
requires:
- test
context: vuestic-admin-staging
filters:
branches:
only: develop
- deploy-production:
requires:
- test
context: vuestic-production
filters:
branches:
only: master