Run `cbx audit` in GitHub Actions
Run cbx audit aws inside a GitHub Actions workflow and gate merges on its exit code.
Run cbx audit in GitHub Actions
This recipe shows you how to run cbx audit aws inside a GitHub Actions workflow so that a non-zero exit code blocks the pull request from merging.
Live-account audits are usually a workstation task
cbx audit aws reads a live AWS account and grounds its findings by running a local LLM CLI (claude or codex). To run it in CI the runner needs AWS credentials, outbound reachability to api.cloudbooster.io, and the chosen LLM CLI installed and authenticated. Many teams run live-account audits from a developer workstation instead. If that's you, skip this page — the example below is for teams that have deliberately set up CI to carry those prerequisites.
Before you begin
cbx-cliinstalled in the runner. The workflow below installs it via the official install script.- AWS credentials available to the workflow (e.g. via
aws-actions/configure-aws-credentialswith OIDC). - The grounding LLM CLI (
claudeorcodex) installed on the runner and authenticated via a secret. The CLI owns its own auth. - Network reachability from the runner to
api.cloudbooster.io.
The workflow
Create .github/workflows/cbx-audit.yml in your repository and paste the contents below. A copy of the same file is also committed in this docs repo as cbx-audit.yml so you can download it directly.
Key points
| Feature | How it works |
|---|---|
| Trigger | pull_request on main audits before merge. |
| Install | The official install script downloads the latest stable cbx-cli binary. Pin a version with CBX_VERSION if you need reproducible builds. |
| Grounding CLI | cbx audit aws always grounds via a local LLM CLI (claude or codex). It must be on the runner's PATH and authenticated — the binary install alone is not enough. |
--no-tui | Disables the interactive TUI (also implied in a non-TTY runner). |
--strict | Treats warnings as failures so they affect the exit code and the merge gate. |
-o json | Emits a machine-readable envelope you can archive as a workflow artifact. |
| Exit-code gating | The step does not set continue-on-error: true. A non-zero exit fails the job and blocks merge (with branch protection requiring the check). |
How PR gating works
GitHub Actions uses the job's exit code to decide whether a required status check passed. By default, any step that returns a non-zero exit code fails the whole job.
To enforce this as a merge gate:
- Open your repository's Settings → Branches.
- Add or edit a branch protection rule for
main. - Enable Require status checks to pass before merging.
- Search for and select the
cbx auditcheck.
Now, when cbx audit aws reports findings at or above your threshold, the check fails and the PR cannot be merged until the issues are resolved or an administrator bypasses the protection.
Non-blocking mode
To see findings without blocking merges during an evaluation period, add continue-on-error: true to the audit step. The findings still surface in the logs, but the job reports success.
What if?
Audit step fails with "command not found"
If cbx isn't found, the install step didn't add it to PATH. Confirm the echo "$HOME/.cbx/bin" >> "$GITHUB_PATH" line ran, then cbx version.
Run aborts with E_LLM_PREFLIGHT
The grounding LLM CLI isn't installed or authenticated on the runner. cbx audit aws probes it before any AWS call. Install claude (or codex), supply its credentials via a repo secret, and re-run.
Can I run this on a schedule instead of per-PR?
Yes. Replace the on: trigger with a schedule event to audit nightly or weekly. Archive the -o json output as a workflow artifact for later review.
Next steps
- Read the
cbx audit awsguide. - Import an existing AWS account with the Import AWS Account guide.