# This config is equivalent to both the '.circleci/extended/orb-free.yml' and the base '.circleci/config.yml' version: 2.1 # Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects. # See: https://circleci.com/docs/2.0/orb-intro/ orbs: node: circleci/node@4.7 jobs: install: &shared-config docker: - image: circleci/node:lts-fermium working_directory: ~/repo steps: - checkout - restore_cache: keys: - dependencies-{{ checksum "package.json" }}-v1 - dependencies- - run: yarn install - save_cache: paths: - node_modules key: dependencies-{{ checksum "package.json" }}-v1 unit-tests: <<: *shared-config steps: - checkout - restore_cache: keys: dependencies-{{ checksum "package.json" }}-v1 - run: yarn test:unit build: <<: *shared-config environment: - VITE_BACKEND_URL_URL: $VITE_BACKEND_URL_URL steps: - checkout - restore_cache: keys: - dependencies-{{ checksum "package.json" }}-v1 - dependencies- - run: yarn build docker-build-and-push: working_directory: /dockerapp docker: - image: docker:17.05.0-ce-git steps: - checkout - setup_remote_docker: version: 19.03.13 - run: name: Build application Docker image command: | docker build --cache-from=app -t app . - deploy: name: Publish application to docker hub command: | docker login -e $DOCKER_HUB_EMAIL -u $DOCKER_HUB_USER_ID -p $DOCKER_HUB_PWD docker tag app $DOCKER_HUB_USER_ID/$DOCKER_HUB_NAME:$CIRCLE_BUILD_NUM docker tag app $DOCKER_HUB_USER_ID/$DOCKER_HUB_NAME:latest docker push $DOCKER_HUB_USER_ID/$DOCKER_HUB_NAME:$CIRCLE_BUILD_NUM docker push $DOCKER_HUB_USER_ID/$DOCKER_HUB_NAME:latest front-netlify-deploy: <<: *shared-config steps: - checkout - restore_cache: keys: - dependencies-{{ checksum "package.json" }}-v1 - dependencies- - run: name: Install netlify command: | yarn add -D netlify-cli - run: name: Deploy app command: yarn netlify deploy --auth $NETLIFY_AUTH_TOKEN --dir ~/repo --site $NETLIFY_SITE_ID --prod # Invoke jobs via workflows # See: https://circleci.com/docs/2.0/configuration-reference/#workflows workflows: sample: # This is the name of the workflow, feel free to change it to better match your workflow. # Inside the workflow, you define the jobs you want to run. jobs: - install - unit-tests: requires: - install - build: requires: - unit-tests - docker-build-and-push: requires: - build filters: branches: only: main - front-netlify-deploy: requires: - build filters: branches: only: main