Skip to content

Commit 61e8ddc

Browse files
Merge pull request #450 from epicmaxco/introducing-CI-master
Introducing ci master
2 parents d3c6d66 + f35ae77 commit 61e8ddc

File tree

6 files changed

+384
-140
lines changed

6 files changed

+384
-140
lines changed

.circleci/config.yml

Lines changed: 84 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,92 @@
1-
# Javascript Node CircleCI 2.0 configuration file
2-
#
3-
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4-
#
1+
aliases:
2+
- &restore_cache
3+
name: Restore Yarn Package Cache
4+
keys:
5+
- yarn-packages-{{ checksum "yarn.lock" }}
6+
7+
- &install_dependencies
8+
name: Install Dependencies
9+
command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
10+
11+
- &save_cache
12+
name: Save Yarn Package Cache
13+
key: yarn-packages-{{ checksum "yarn.lock" }}
14+
paths:
15+
- ~/.cache/yarn
16+
17+
- &build |
18+
yarn build
19+
20+
docker: &docker
21+
docker:
22+
- image: circleci/node:10.12.0
23+
24+
defaults: &defaults
25+
<<: *docker
26+
parallelism: 1
27+
working_directory: ~/repo
28+
529
version: 2
630
jobs:
7-
deploy:
8-
docker:
9-
- image: circleci/node:10.12.0
10-
parallelism: 1
11-
working_directory: ~/repo
31+
deploy-staging:
32+
<<: *defaults
33+
steps:
34+
- checkout
35+
- restore_cache: *restore_cache
36+
- run: *install_dependencies
37+
- save_cache: *save_cache
38+
- run: *build
39+
- run:
40+
name: Deploy to hosting
41+
command: |
42+
tar -czf dist.tar.gz ~/repo/dist -C ~/repo/dist .
43+
sudo apt install sshpass
44+
ssh-keyscan -t rsa $DEPLOY_URL >> ~/.ssh/known_hosts
45+
sshpass -p $DEPLOY_PASSWORD scp ~/repo/dist.tar.gz $DEPLOY_USER@$DEPLOY_URL:~/tmp
46+
sshpass -p $DEPLOY_PASSWORD ssh $DEPLOY_USER@$DEPLOY_URL /bin/bash << EOF
47+
rm -rf $DEPLOY_PATH/*
48+
tar -xzf ~/tmp/dist.tar.gz -C $DEPLOY_PATH
49+
rm -f ~/tmp/dist.tar.gz
50+
EOF
51+
52+
deploy-production:
53+
<<: *defaults
1254
steps:
13-
- checkout
14-
- restore_cache:
15-
name: Restore Yarn Package Cache
16-
keys:
17-
- yarn-packages-{{ checksum "yarn.lock" }}
18-
- run:
19-
name: Install Dependencies
20-
command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
21-
- save_cache:
22-
name: Save Yarn Package Cache
23-
key: yarn-packages-{{ checksum "yarn.lock" }}
24-
paths:
25-
- ~/.cache/yarn
26-
- run: yarn build
27-
- run:
28-
name: Deploy to hosting
29-
# Package dist folder
30-
# Do some hacks to be able to copy file without ssh key (only with user/password). That's not needed for normal hosting
31-
# Copy package to tmp folder
32-
# On remote host:
33-
# - remove public folder contents
34-
# - unpack bundle archive into public folder
35-
# - remove bundle archive
36-
command: |
37-
tar -czf dist.tar.gz ~/repo/dist -C ~/repo/dist .
38-
sudo apt install sshpass
39-
ssh-keyscan -t rsa $DEPLOY_URL >> ~/.ssh/known_hosts
40-
sshpass -p $DEPLOY_PASSWORD scp ~/repo/dist.tar.gz $DEPLOY_USER@$DEPLOY_URL:~/tmp
41-
sshpass -p $DEPLOY_PASSWORD ssh $DEPLOY_USER@$DEPLOY_URL /bin/bash << EOF
42-
rm -rf $DEPLOY_PATH/*
43-
tar -xzf ~/tmp/dist.tar.gz -C $DEPLOY_PATH
44-
rm -f ~/tmp/dist.tar.gz
45-
EOF
55+
- checkout
56+
- run:
57+
name: Add variables for Yandex Metrics and Drift live chat
58+
command:
59+
echo "VUE_APP_YANDEX_METRICS_KEY=$YANDEX_METRICS_KEY" >> .env.production.local &&
60+
echo "VUE_APP_DRIFT_KEY=$DRIFT_KEY" >> .env.production.local
61+
- restore_cache: *restore_cache
62+
- run: *install_dependencies
63+
- save_cache: *save_cache
64+
- run: *build
65+
- run:
66+
name: Deploy to hosting
67+
environment:
68+
DEPLOY_PATH: /var/www/html/vuestic-admin
69+
command: |
70+
tar -czf dist.tar.gz ~/repo/dist -C ~/repo/dist .
71+
ssh-keyscan -t rsa $SERVER_IP >> ~/.ssh/known_hosts
72+
scp ~/repo/dist.tar.gz $SERVER_USER_NAME@$SERVER_IP:~/
73+
ssh $SERVER_USER_NAME@$SERVER_IP << EOF
74+
mkdir -p tmp
75+
rm -rf $DEPLOY_PATH/*
76+
tar -xzf ~/dist.tar.gz -C $DEPLOY_PATH
77+
rm -rf ~/dist.tar.gz ~/tmp
78+
EOF
4679
4780
workflows:
4881
version: 2
4982
build-and-deploy:
5083
jobs:
51-
- deploy:
52-
filters:
53-
branches:
54-
only: develop
84+
- deploy-staging:
85+
filters:
86+
branches:
87+
only: develop
88+
- deploy-production:
89+
context: vuestic-production
90+
filters:
91+
branches:
92+
only: master

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
VUE_APP_YANDEX_METRICS_KEY=
2+
VUE_APP_DRIFT_KEY=

0 commit comments

Comments
 (0)