config.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. aliases:
  2. - &restore_cache
  3. name: Restore Yarn Package Cache
  4. keys:
  5. - yarn-packages-{{ checksum "yarn.lock" }}
  6. - &install_dependencies
  7. name: Install Dependencies
  8. command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
  9. - &save_cache
  10. name: Save Yarn Package Cache
  11. key: yarn-packages-{{ checksum "yarn.lock" }}
  12. paths:
  13. - ~/.cache/yarn
  14. docker: &docker
  15. docker:
  16. - image: cimg/node:16.16.0
  17. defaults: &defaults
  18. <<: *docker
  19. parallelism: 1
  20. working_directory: ~/repo
  21. version: 2
  22. jobs:
  23. test:
  24. <<: *defaults
  25. steps:
  26. - checkout
  27. - restore_cache: *restore_cache
  28. - run: *install_dependencies
  29. - save_cache: *save_cache
  30. - run: yarn test:unit
  31. deploy-staging:
  32. <<: *defaults
  33. steps:
  34. - checkout
  35. - run:
  36. name: Add variables
  37. command:
  38. echo "VUE_APP_INCLUDE_DEMOS=true" >> .env.production.local &&
  39. echo "VUE_APP_BUILD_VERSION=true" >> .env.production.local &&
  40. echo "VUE_APP_GTM_ENABLED=false" >> .env.production.local
  41. - restore_cache: *restore_cache
  42. - run: *install_dependencies
  43. - save_cache: *save_cache
  44. - run: yarn build:ci
  45. - add_ssh_keys:
  46. fingerprints:
  47. - "f8:c0:94:79:68:a2:5e:33:9f:78:bc:ad:ed:86:c6:3c"
  48. - run:
  49. name: Add $SERVER_IP to known_hosts
  50. command: ssh-keyscan -H $SERVER_IP >> ~/.ssh/known_hosts
  51. - run:
  52. name: Deploy to hosting
  53. command: |
  54. tar -czf dist.tar.gz ~/repo/dist -C ~/repo/dist .
  55. scp ~/repo/dist.tar.gz $SERVER_USER@$SERVER_IP:~/tmp
  56. ssh $SERVER_USER@$SERVER_IP /bin/bash << EOF
  57. rm -rf $DEPLOY_PATH/*
  58. tar -xzf ~/tmp/dist.tar.gz -C $DEPLOY_PATH
  59. rm -f ~/tmp/dist.tar.gz
  60. EOF
  61. deploy-production:
  62. <<: *defaults
  63. steps:
  64. - checkout
  65. - run:
  66. name: Add variables
  67. command:
  68. echo "VUE_APP_YANDEX_METRICS_KEY=$YANDEX_METRICS_KEY" >> .env.production.local &&
  69. echo "VUE_APP_DRIFT_KEY=$DRIFT_KEY" >> .env.production.local &&
  70. echo "VITE_APP_GTM_KEY=$GTM_KEY" >> .env.production.local &&
  71. echo "VITE_APP_GTM_ENABLED=$GTM_ENABLED" >> .env.production.local &&
  72. echo "VUE_APP_GTM_ENABLED=true" >> .env.production.local &&
  73. echo "VUE_APP_ROUTER_MODE_HISTORY=$ROUTER_MODE_HISTORY" >> .env.production.local
  74. - restore_cache: *restore_cache
  75. - run: *install_dependencies
  76. - save_cache: *save_cache
  77. - run: yarn build:ci
  78. - run:
  79. name: Deploy to hosting
  80. command: |
  81. tar -czf dist.tar.gz ~/repo/dist -C ~/repo/dist .
  82. ssh-keyscan -t rsa $SERVER_IP >> ~/.ssh/known_hosts
  83. scp ~/repo/dist.tar.gz $SERVER_USERNAME@$SERVER_IP:~/
  84. ssh $SERVER_USERNAME@$SERVER_IP << EOF
  85. mkdir -p tmp
  86. rm -rf $PRODUCTION_DEPLOY_PATH/*
  87. tar -xzf ~/dist.tar.gz -C $PRODUCTION_DEPLOY_PATH
  88. rm -rf ~/dist.tar.gz ~/tmp
  89. EOF
  90. workflows:
  91. version: 2
  92. build-and-deploy:
  93. jobs:
  94. # - test
  95. - deploy-staging:
  96. # requires:
  97. # - test
  98. context: vuestic-admin-staging
  99. filters:
  100. branches:
  101. only: develop
  102. - deploy-production:
  103. # requires:
  104. # - test
  105. context: vuestic-production
  106. filters:
  107. branches:
  108. only: master