Skip to content

Continuous integration/delivery (CI/CD)

Continuous integration (CI) and Continuous delivery (CD) is essetial in todays software development cycle. Flox environments can take you CI/CD pipelines to the next level, making them robust and reproducible. Let us look how can you use Flox with some of the CI/CD platforms.

Github Actions

There are two actions that you can use in a Github workflow:

  • flox/install-flox-action (installs Flox CLI)
  • flox/activate-action (runs command in the context of Flox environment)

An example GitHub workflow:

.github/workflows/ci.yml
name: "CI"

... # (1)!

jobs:

  build:
    name: "Build website"
    runs-on: "ubuntu-latest"
    steps:
      - name: "Checkout"
        uses: "actions/checkout@v4"

      - name: "Install Flox" # (2)!
        uses: "flox/install-flox-action@v2"

      - name: "Build" # (3)!
        uses: "flox/activate-action@v1"
        with:
          command: npm run build

      ...
  1. You are looking at an example project, your project will probably look a little different. Important parts of how to integrate Flox with Github Actions are highlighted bellow.
  2. flox/install-flox-action will install latest version Flox.
  3. flox/activate-action allows you to run a command inside the Flox environment.

CircleCI

There is a Flox Orb that can help you use Flox inside CircleCI.

An example CircleCI workflow:

.circleci/config.yml
version: 2.1

orbs:
  flox: flox/[email protected]

jobs:
  build:
    machine:
      image: ubuntu-2204:current
    steps:
      - checkout
      - flox/install # (1)!
      - flox/activate: # (2)!
          command: "npm run build"
  1. The install command will install the latest Flox version. You can change the channel and version option which allows you to select excatly which version of Flox to install.
  2. The activate command runs a command in the context of a Flox environment.

GitLab

An example GitLab pipeline:

.gitlab-ci.yml
build:
  stage: build
  image: ghcr.io/flox/flox:latest # (1)!
  script:
    - flox activate -- npm run build # (2)!
  1. Use ghcr.io/flox/flox that already comes with Flox.
  2. Run command in a Flox environment.

Where to next?