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:
-
Enable CircleCI for your source code repository containing the source code you want to deploy
-
Enable and activate pipelines in the CircleCI project (Project Settings → Advanced Settings)
-
Create a service token for your project
-
Get the name or preferably UUID of your project, which can be obtained by running
kalix projects list
Create an authentication context
The kalix
orb expects the authentication token and project ID as parameters. CircleCI context allows you to store the authentication token and project ID values securely using a context.
In your CircleCI account, create a context and:
-
Store the authentication token as
KALIX_TOKEN
. -
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:
-
Create a folder named
.circleci
at the root of the project folder. -
Create a file named
config.yml
in the.circleci
folder. -
Open
config.yml
for editing and add the CircleCI version:version: 2.1
-
Reference the orb:
orbs: kalix: lightbend/kalix@1.0.0
-
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 theKALIX_TOKEN
andKALIX_PROJECT
environment variables set in the CircleCI context.2 The kalix/exec
command executes any command from the Kalix CLI. Do not precede commands withkalix
. -
Add a workflow 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 a workflow.
-
Save
.config.yml
.