Skip to content

Commit

Permalink
feat(project): update circle ci config: add aliases and make some ref…
Browse files Browse the repository at this point in the history
…actoring / renaming
  • Loading branch information
alexanderrudnik committed Jan 10, 2019
1 parent 3915e70 commit 53fcfa0
Showing 1 changed file with 47 additions and 62 deletions.
109 changes: 47 additions & 62 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
# 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-dev:
docker:
- image: circleci/node:10.12.0
parallelism: 1
working_directory: ~/repo
deploy-staging:
<<: *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
- restore_cache: *restore_cache
- run: *install_dependencies
- save_cache: *save_cache
- run: *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
Expand All @@ -44,42 +49,23 @@ jobs:
rm -f ~/tmp/dist.tar.gz
EOF
deploy-prod:
docker:
- image: circleci/node:10.12.0
parallelism: 1
working_directory: ~/repo
deploy-production:
<<: *defaults
steps:
- 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:
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
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
# 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
Expand All @@ -96,13 +82,12 @@ workflows:
version: 2
build-and-deploy:
jobs:
- deploy-dev:
- deploy-staging:
filters:
branches:
only: develop
- deploy-prod:
context: vuestic-prod
- deploy-production:
context: vuestic-production
filters:
branches:
only: master

0 comments on commit 53fcfa0

Please sign in to comment.