diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..5e5391ce6 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,171 @@ +version: 2.1 +orbs: + #snyk: snyk/snyk@0.0.8 + #cypress: cypress-io/cypress@1.23.0 + aws-s3: circleci/aws-s3@2.0.0 + eb: circleci/aws-elastic-beanstalk@1.0.2 + jira: circleci/jira@1.3.1 +jobs: + api-deploy: + docker: + - image: "cimg/base:stable" + steps: + - checkout + - eb/setup + - run: + command: | + eb init imex-online-production-api -r ca-central-1 -p "Node.js 16 running on 64bit Amazon Linux 2" + eb status --verbose + eb deploy + eb status + - jira/notify + + hasura-migrate: + docker: + - image: cimg/node:16.15.0 + + working_directory: ~/repo/hasura + steps: + - checkout: + path: ~/repo + - run: + name: Execute migration + command: | + npm install hasura-cli -g + hasura migrate apply --endpoint https://db.imex.online/ --admin-secret $HASURA_PROD_SECRET + hasura metadata apply --endpoint https://db.imex.online/ --admin-secret $HASURA_PROD_SECRET + hasura metadata reload --endpoint https://db.imex.online/ --admin-secret $HASURA_PROD_SECRET + + app-build: + docker: + - image: cimg/node:16.15.0 + + working_directory: ~/repo/client + + steps: + - checkout: + path: ~/repo + + - 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 run build + + - aws-s3/sync: + from: build + to: "s3://imex-online-production/" + - jira/notify + + test-hasura-migrate: + docker: + - image: cimg/node:16.15.0 + + working_directory: ~/repo/hasura + steps: + - checkout: + path: ~/repo + - run: + name: Execute migration + command: | + npm install hasura-cli -g + hasura migrate apply --endpoint https://db.test.bodyshop.app/ --admin-secret $HASURA_TEST_SECRET + hasura metadata apply --endpoint https://db.test.bodyshop.app/ --admin-secret $HASURA_TEST_SECRET + hasura metadata reload --endpoint https://db.test.bodyshop.app/ --admin-secret $HASURA_TEST_SECRET + + test-app-build: + docker: + - image: cimg/node:16.15.0 + + working_directory: ~/repo/client + + steps: + - checkout: + path: ~/repo + + - 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 run build:test + + - aws-s3/sync: + from: build + to: "s3://imex-online-test/" + - jira/notify + + admin-app-build: + docker: + - image: cimg/node:16.15.0 + + working_directory: ~/repo/admin + + steps: + - checkout: + path: ~/repo + + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + - run: npm i + + - save_cache: + paths: + - node_modules + - ~/.npm + - ~/.cache + key: v1-dependencies-{{ checksum "package.json" }} + + - run: npm run build + + - aws-s3/sync: + from: build + to: "s3://adm.imex.online/" + +workflows: + deploy_and_build: + jobs: + - api-deploy: + filters: + branches: + only: master + - app-build: + filters: + branches: + only: master + - hasura-migrate: + filters: + branches: + only: master + - test-app-build: + filters: + branches: + only: test + - test-hasura-migrate: + filters: + branches: + only: test + #- admin-app-build: + #filters: + #branches: + #only: master diff --git a/.gitignore b/.gitignore index 3fbb87926..2175cc7a9 100644 --- a/.gitignore +++ b/.gitignore @@ -115,4 +115,6 @@ firebase/.env logs/oAuthClient-log.log -.node-persist/** \ No newline at end of file +.node-persist/** + +*.env.* \ No newline at end of file