GitHub Actions
1 min read
Use the OpenCX CLI in GitHub Actions to validate content on every push or pull request.
Basic Workflow
This workflow runs content check to validate content files, and content gate to detect drift against the remote.
yaml
name: Content CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
content:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- name: Validate content
run: bunx @opencx/cli content check
- name: Gate content
env:
OPENCX_API_KEY: ${{ secrets.OPENCX_API_KEY }}
run: bunx @opencx/cli content gate
Both commands exit with code 1 on failure, so the workflow fails automatically when content is invalid or out of sync.
Check-Only Workflow
If you only need local validation (no remote comparison), you can skip the gate step. This does not require OPENCX_API_KEY.
yaml
- name: Validate content
run: bunx @opencx/cli content check
JSON Output
Use --json for machine-readable output, useful for downstream steps or custom reporting.
yaml
- name: Gate content (JSON)
env:
OPENCX_API_KEY: ${{ secrets.OPENCX_API_KEY }}
run: bunx @opencx/cli content gate --json
The gate JSON output has the following shape:
json
{
"valid": true,
"synced": true,
"check": { "valid": true, "errors": [], "stats": {} },
"diff": { "hasChanges": false }
}
Environment Variables
| Variable | Required | Description |
|---|---|---|
OPENCX_API_KEY | For gate only | API key for remote comparison |
OPENCX_API_URL | No | Custom API URL (defaults to production) |
Store OPENCX_API_KEY as a repository secret in your GitHub repository settings.