CI/CD setup for website via CircleCI

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1212
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    815

Configuring CI/CD for Your Website with CircleCI

CircleCI is a cloud-based CI/CD platform focused on speed. It uses the concept of orbs (reusable configuration packages) and resource classes for fine-tuning resources per job. Configuration is stored in .circleci/config.yml.

Basic Configuration

version: 2.1

orbs:
  node: circleci/[email protected]

jobs:
  test:
    docker:
      - image: cimg/node:20.11
    steps:
      - checkout
      - node/install-packages:
          pkg-manager: npm
      - run:
          name: Run tests
          command: npm test

  build:
    docker:
      - image: cimg/node:20.11
    steps:
      - checkout
      - node/install-packages:
          pkg-manager: npm
      - run: npm run build
      - persist_to_workspace:
          root: .
          paths:
            - dist/

  deploy:
    docker:
      - image: cimg/base:2024.01
    steps:
      - attach_workspace:
          at: .
      - add_ssh_keys:
          fingerprints:
            - "SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      - run:
          name: Deploy via rsync
          command: |
            rsync -avz --delete dist/ deploy@$DEPLOY_HOST:/var/www/mysite/

workflows:
  build-test-deploy:
    jobs:
      - test
      - build:
          requires:
            - test
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: main

Workspaces

persist_to_workspace / attach_workspace is a mechanism for passing files between jobs in a single workflow. Build artifacts (the dist/ folder) are created in the build job and picked up in the deploy job. This works faster than caching because data is stored in CircleCI's in-memory storage for the duration of the workflow.

Orbs

Orbs are reusable configuration blocks published in the registry. They save dozens of lines of YAML:

orbs:
  aws-s3: circleci/[email protected]
  slack: circleci/[email protected]

jobs:
  deploy_s3:
    docker:
      - image: cimg/python:3.12
    steps:
      - attach_workspace:
          at: .
      - aws-s3/sync:
          from: dist/
          to: s3://my-bucket/
          arguments: --delete
      - slack/notify:
          event: pass
          template: basic_success_1

Popular orbs: circleci/aws-s3, circleci/kubernetes, circleci/docker, circleci/slack, circleci/heroku.

Resource Classes

Different jobs require different resources. Tests can run on small machines, while Docker image builds need more:

jobs:
  lint:
    resource_class: small       # 1 CPU, 2GB RAM — cheaper
    docker:
      - image: cimg/node:20.11

  build_docker:
    resource_class: large       # 4 CPU, 8GB RAM
    machine:
      image: ubuntu-2204:current

Classes: small, medium (default), medium+, large, xlarge, 2xlarge. Cost in credits is proportional.

Parallel Test Execution

CircleCI can automatically split test suites across N parallel containers:

test:
  parallelism: 4
  docker:
    - image: cimg/node:20.11
  steps:
    - checkout
    - node/install-packages
    - run:
        name: Split and run tests
        command: |
          TESTFILES=$(circleci tests glob "**/*.test.ts" | circleci tests split --split-by=timings)
          npx jest $TESTFILES
    - store_test_results:
        path: test-results/

circleci tests split --split-by=timings splits files based on historical execution time data, balancing load across containers. With 4 containers, tests run approximately 4x faster.

Conditional Steps and Approval

workflows:
  deploy:
    jobs:
      - build
      - hold:
          type: approval       # waits for manual click in UI
          requires:
            - build
      - deploy_production:
          requires:
            - hold
          filters:
            branches:
              only: main

type: approval is a pause job that requires confirmation in CircleCI UI. Useful for production deployments.

SSH Access to Failed Builds

When a build fails, you can reconnect to the container:

circleci ssh --job JOB_ID

Or enable in configuration:

- run:
    when: on_fail
    command: sleep 600   # keeps container for 10 minutes for SSH debugging

Storing Artifacts and Test Results

- store_artifacts:
    path: dist/
    destination: build-output

- store_test_results:
    path: test-results/

Artifacts are available in the UI on the Artifacts tab. Test results in JUnit XML format are displayed on the Tests tab with breakdown by suites.

Implementation Timeline

First working pipeline — 1 day: creating .circleci/config.yml, adding SSH keys and environment variables to the project, debugging. Complete configuration with parallel tests, orbs, and approval flow — 2–3 days.