-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #450 from epicmaxco/introducing-CI-master
Introducing ci master
- Loading branch information
Showing
6 changed files
with
384 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,92 @@ | ||
# Javascript Node CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | ||
# | ||
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 | ||
|
||
- &build | | ||
yarn build | ||
|
||
docker: &docker | ||
docker: | ||
- image: circleci/node:10.12.0 | ||
|
||
defaults: &defaults | ||
<<: *docker | ||
parallelism: 1 | ||
working_directory: ~/repo | ||
|
||
version: 2 | ||
jobs: | ||
deploy: | ||
docker: | ||
- image: circleci/node:10.12.0 | ||
parallelism: 1 | ||
working_directory: ~/repo | ||
deploy-staging: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- restore_cache: *restore_cache | ||
- run: *install_dependencies | ||
- save_cache: *save_cache | ||
- run: *build | ||
- run: | ||
name: Deploy to hosting | ||
command: | | ||
tar -czf dist.tar.gz ~/repo/dist -C ~/repo/dist . | ||
sudo apt install sshpass | ||
ssh-keyscan -t rsa $DEPLOY_URL >> ~/.ssh/known_hosts | ||
sshpass -p $DEPLOY_PASSWORD scp ~/repo/dist.tar.gz $DEPLOY_USER@$DEPLOY_URL:~/tmp | ||
sshpass -p $DEPLOY_PASSWORD ssh $DEPLOY_USER@$DEPLOY_URL /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 | ||
- restore_cache: | ||
name: Restore Yarn Package Cache | ||
keys: | ||
- yarn-packages-{{ checksum "yarn.lock" }} | ||
- run: | ||
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 | ||
- run: yarn build | ||
- run: | ||
name: Deploy to hosting | ||
# Package dist folder | ||
# Do some hacks to be able to copy file without ssh key (only with user/password). That's not needed for normal hosting | ||
# Copy package to tmp folder | ||
# On remote host: | ||
# - remove public folder contents | ||
# - unpack bundle archive into public folder | ||
# - remove bundle archive | ||
command: | | ||
tar -czf dist.tar.gz ~/repo/dist -C ~/repo/dist . | ||
sudo apt install sshpass | ||
ssh-keyscan -t rsa $DEPLOY_URL >> ~/.ssh/known_hosts | ||
sshpass -p $DEPLOY_PASSWORD scp ~/repo/dist.tar.gz $DEPLOY_USER@$DEPLOY_URL:~/tmp | ||
sshpass -p $DEPLOY_PASSWORD ssh $DEPLOY_USER@$DEPLOY_URL /bin/bash << EOF | ||
rm -rf $DEPLOY_PATH/* | ||
tar -xzf ~/tmp/dist.tar.gz -C $DEPLOY_PATH | ||
rm -f ~/tmp/dist.tar.gz | ||
EOF | ||
- checkout | ||
- run: | ||
name: Add variables for Yandex Metrics and Drift live chat | ||
command: | ||
echo "VUE_APP_YANDEX_METRICS_KEY=$YANDEX_METRICS_KEY" >> .env.production.local && | ||
echo "VUE_APP_DRIFT_KEY=$DRIFT_KEY" >> .env.production.local | ||
- restore_cache: *restore_cache | ||
- run: *install_dependencies | ||
- save_cache: *save_cache | ||
- run: *build | ||
- run: | ||
name: Deploy to hosting | ||
environment: | ||
DEPLOY_PATH: /var/www/html/vuestic-admin | ||
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_USER_NAME@$SERVER_IP:~/ | ||
ssh $SERVER_USER_NAME@$SERVER_IP << EOF | ||
mkdir -p tmp | ||
rm -rf $DEPLOY_PATH/* | ||
tar -xzf ~/dist.tar.gz -C $DEPLOY_PATH | ||
rm -rf ~/dist.tar.gz ~/tmp | ||
EOF | ||
workflows: | ||
version: 2 | ||
build-and-deploy: | ||
jobs: | ||
- deploy: | ||
filters: | ||
branches: | ||
only: develop | ||
- deploy-staging: | ||
filters: | ||
branches: | ||
only: develop | ||
- deploy-production: | ||
context: vuestic-production | ||
filters: | ||
branches: | ||
only: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
VUE_APP_YANDEX_METRICS_KEY= | ||
VUE_APP_DRIFT_KEY= |
Oops, something went wrong.