Automating Cerbos Policy deployments with CircleCI
Published by Alex Olivier on July 09, 2025
This guide will help you set up a CI/CD pipeline in CircleCI to automatically upload your Cerbos policies to a Cerbos Hub store whenever you push changes to the main branch of your Git repository.
Prerequisites
- A CircleCI account, linked to your GitHub or Bitbucket account.
- Your repository "set up" as a project in CircleCI.
- The ID of your Cerbos Hub store, which you can find in the store section of the Cerbos Hub.
- Your
CERBOS_HUB_CLIENT_IDandCERBOS_HUB_CLIENT_SECRETvalues generated in the Client credentials section of the Cerbos Hub store. Make sure to select theRead & Writeoption when creating the credentials to allow uploading policies.
Step 1: Create the Config File
- In your repository, create a directory named
.circleci. - Inside
.circleci, create a file namedconfig.yml. - Copy and paste the following code into it.
- Replace
[STORE_ID]with the ID of your Cerbos Hub store. You can find this in the Cerbos Hub UI under the store settings.
# .circleci/config.yml
version: 2.1
jobs:
upload-policies:
docker:
- image: cimg/base:2024.01
steps:
- checkout
- setup_remote_docker:
version: 20.10.24
- run:
name: Upload Policies
command: |
docker run --rm \
-e CERBOS_HUB_STORE_ID="[STORE_ID]" \
-e CERBOS_HUB_CLIENT_ID=$CERBOS_HUB_CLIENT_ID \
-e CERBOS_HUB_CLIENT_SECRET=$CERBOS_HUB_CLIENT_SECRET \
-v "$(pwd)":/app \
ghcr.io/cerbos/cerbosctl:latest \
hub store replace-files /app --message="Policy upload from CircleCI"
workflows:
build-and-upload:
jobs:
- upload-policies:
filters:
branches:
only: main
Step 2: Add Your Secrets
- Go to the CircleCI dashboard and select your project.
- Click Project Settings in the upper right.
- In the sidebar, click Environment Variables.
- Click Add Environment Variable.
- Enter
CERBOS_HUB_CLIENT_IDas the Name and paste your client ID as the Value. Click Add Environment Variable. - Repeat for
CERBOS_HUB_CLIENT_SECRET.
Step 3: Commit and Push
- Commit the
.circleci/config.ymlfile. - Push your changes to the
mainbranch.
Step 4: Verify the Run
- Go to your project's dashboard in CircleCI.
- You will see a new workflow running. Click on it to see the status of the
upload-policiesjob.
Book a free Policy Workshop to discuss your requirements and get your first policy written by the Cerbos team
Recommended content

Mapping business requirements to authorization policy
eBook: Zero Trust for AI, securing MCP servers

Experiment, learn, and prototype with Cerbos Playground
eBook: How to adopt externalized authorization

Framework for evaluating authorization providers and solutions

Staying compliant – What you need to know
Subscribe to our newsletter
Join thousands of developers | Features and updates | 1x per month | No spam, just goodies.
