From 53fcfa0b1c44246786b478b587758f6c194fcf34 Mon Sep 17 00:00:00 2001 From: alexanderrudnik Date: Thu, 10 Jan 2019 20:57:59 +0300 Subject: [PATCH] feat(project): update circle ci config: add aliases and make some refactoring / renaming --- .circleci/config.yml | 109 +++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 62 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 37e7027d2..ad6159e90 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -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 @@ -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 -