CI/CD Gate
cloudrift is designed to run inside CI/CD pipelines. Two features make it CI-friendly:
--format markdownproduces a report ready for PR comments / step summarycostAlertThresholdUsdin the config exits with code 2 when waste exceeds the budget
Configuration
In the cloudrift.config.json file (committed to the repo):
{
"costAlertThresholdUsd": 500,
"minAgeDays": 7,
"ignoreTag": "cloudrift:ignore"
}
If the total waste exceeds costAlertThresholdUsd, the command exits with code 2 → pipeline fails. Savings of type optimization never count towards the gate.
GitHub Actions — full example
name: Cloud cost check
on: [pull_request]
permissions:
contents: read
jobs:
cloudrift:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: elleVas/cloudrift
path: cloudrift-cli
- uses: pnpm/action-setup@v4
with: { version: 9 }
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: cloudrift-cli/pnpm-lock.yaml
- run: pnpm install --frozen-lockfile
working-directory: cloudrift-cli
- run: pnpm nx build cli
working-directory: cloudrift-cli
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
# Publish report to step summary; exits 2 if over budget
- run: node cloudrift-cli/apps/cli/dist/main.js analyze -r us-east-1 eu-west-1 --format markdown >> "$GITHUB_STEP_SUMMARY"
Exit codes
| Code | Meaning |
|---|---|
| 0 | Scan completed, waste below threshold (or no threshold configured) |
| 2 | Total waste exceeds costAlertThresholdUsd — pipeline blocked |
Notes
- In CI (or when stdout is not a TTY), the interactive picker doesn’t appear: all scanners run automatically
- Once
@cloudrift/cliis published on npm, build steps will reduce tonpx @cloudrift/cli@latest analyze … cloudrift.config.jsonis read from the current working directory — commit it to the repo to share with the team