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/node:18 steps: - checkout - eb/setup - run: command: | eb init imex-online-production-api -r ca-central-1 -p "Node.js 18 running on 64bit Amazon Linux 2" eb status --verbose eb deploy eb status - jira/notify hasura-migrate: docker: - image: cimg/node:16.15.0 parameters: secret: type: string default: $HASURA_PROD_SECRET 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 << parameters.secret >> hasura metadata apply --endpoint https://db.imex.online/ --admin-secret << parameters.secret >> hasura metadata reload --endpoint https://db.imex.online/ --admin-secret << parameters.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 parameters: secret: type: string default: $HASURA_TEST_SECRET working_directory: ~/repo/hasura steps: - checkout: path: ~/repo - run: name: Execute migration command: | npm install hasura-cli -g echo ${HASURA_TEST_SECRET} hasura migrate apply --endpoint https://db.test.bodyshop.app/ --admin-secret << parameters.secret >> hasura metadata apply --endpoint https://db.test.bodyshop.app/ --admin-secret << parameters.secret >> hasura metadata reload --endpoint https://db.test.bodyshop.app/ --admin-secret << parameters.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: secret: ${HASURA_PROD_SECRET} filters: branches: only: master - test-app-build: filters: branches: only: test - test-hasura-migrate: secret: ${HASURA_TEST_SECRET} filters: branches: only: test #- admin-app-build: #filters: #branches: #only: master