CI/CD with CircleCI

Use the kalix orb to use CircleCI with your Kalix project. The orb supports commands for installing, authenticating, and invoking the Kalix CLI.

Prerequisites

To use the kalix orb, you’ll need to:

Create an authentication context

The kalix orb expects the authentication token and project ID as parameters. CircleCI context new tab allows you to store the authentication token and project ID values securely using a context.

In your CircleCI account, create a context new tab and:

  1. Store the authentication token as KALIX_TOKEN.

  2. Store the project ID as KALIX_PROJECT.

With the authentication variables saved, you can use them in your project configuration.

Create a workflow

Follow these steps to create a workflow to invoke the kalix orb for your project:

  1. Create a folder named .circleci at the root of the project folder.

  2. Create a file named config.yml in the .circleci folder.

  3. Open config.yml for editing and add the CircleCI version:

    version: 2.1
  4. Reference the orb:

    orbs:
      kalix: lightbend/kalix@1.0.0
  5. Add a job that creates an image and invokes orb commands. For example, to deploy a service named my-service:

    jobs:
      run-kalix:
        docker:
          - image: 'cimg/base:stable'
        steps:
          - checkout
          - kalix/install (1)
          - kalix/exec: (2)
              cmd: services deploy my-service cimg/base:stable
    1 The kalix/install command installs the Kalix CLI for your CircleCI job and configures it using the KALIX_TOKEN and KALIX_PROJECT environment variables set in the CircleCI context.
    2 The kalix/exec command executes any command from the Kalix CLI. Do not precede commands with kalix.
  6. Add a workflow new tab to schedule the job and give it access to the context storing the authentication variables. For example, with a refresh token and project ID stored in kalix-context:

    workflows:
      version: 1
      install-and-run-kalix:
        jobs:
          - run-kalix
          context:
          - kalix-context

    By default, CircleCI jobs are triggered by any push to the repository. See the documentation for scheduling new tab a workflow.

  7. Save .config.yml.