Examples
CI/CD integration
Gate, validate, and auto-commit Socotra changes from your pipeline.
Use
--output json when consuming results programmatically and --detailed-exit-codes to distinguish "no changes" (0) from "changes made" (2).Validate on every PR (GitHub Actions)
.github/workflows/socotra-validate.yml
name: Socotra validate
on: [pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- run: dotnet tool install -g EssaLab.Socotra
- run: socotra validate --output json
- run: socotra plan --detailed-exit-codes
# Exit 0 = no changes, 2 = changes pending, 1 = errorAuto-apply on main (PowerShell)
apply.ps1
dotnet socotra plan --detailed-exit-codes
if ($LASTEXITCODE -eq 2) {
dotnet socotra apply --auto-approve
git add .
git commit -m "chore: apply socotra changes"
git push
} elseif ($LASTEXITCODE -ne 0) {
Write-Error "socotra plan failed"
exit 1
}Nightly drift detection
#!/usr/bin/env bash
set -euo pipefail
result=$(socotra diff --output json)
drift=$(echo "$result" | jq '.driftCount')
if [ "$drift" -gt 0 ]; then
echo "::warning::Drift detected: $drift change(s)"
echo "$result" | jq '.differences'
exit 2
fiSchema 1.1 · CLI 1.0