CI/CD Integration
Integrate Intrig into your continuous integration and deployment pipelines for automated SDK generation and type-safe builds.
Overview
Intrig supports a CI workflow where:
- Normalized specs are committed to git - The
intrig synccommand fetches and normalizes OpenAPI specifications into the.intrigdirectory - Generated SDK is git-ignored - The
intrig generatecommand outputs compiled TypeScript tonode_modules/@intrig, which should not be committed - CI regenerates SDK from committed specs - Each build runs
intrig generateto produce the SDK from the committed normalized specifications
This approach ensures reproducible builds while keeping generated code out of version control.
The --ci Flag
Use the --ci flag for all Intrig commands in CI environments:
intrig generate --ci
intrig sync --all --ci
Behavior with --ci:
- No daemon startup - Runs without the background daemon process
- Non-interactive mode - Skips all prompts, using defaults or failing if input is required
- Explicit exit codes - Returns non-zero exit code on any failure
- Optimized for automation - No progress spinners or interactive UI elements
Recommended Workflow
Local Development
- Run
intrig syncwhen API specifications change - Commit the normalized specs (
.intrigdirectory) to the repository - Run
intrig generatefor local development
CI Pipeline
- Install dependencies (
npm cior equivalent) - Run
intrig generate --cias a pre-build step - Run regular build (TypeScript compilation, bundling, etc.)
Breaking changes in API specs surface as TypeScript compilation errors, blocking the build before deployment.
Pipeline Examples
GitHub Actions
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npx intrig generate --ci
- run: npm run build
GitLab CI
build:
stage: build
script:
- npm ci
- npx intrig generate --ci
- npm run build
Generic (Any CI)
npm ci
npx intrig generate --ci
npm run build
Failure Handling
When intrig generate --ci Fails
- Exit code is non-zero
- CI pipeline stops immediately
- Check logs for spec validation errors or generation issues
- Verify the
.intrigdirectory contains valid normalized specifications
When TypeScript Compilation Fails After Successful Generation
- Indicates a breaking API change
- Review spec changes in committed normalized specs (
.intrigdirectory) - Update application code to match the new API contract
- Common issues: renamed endpoints, changed parameter types, removed fields
Advanced: Full Contract Validation (Experimental)
This workflow pattern is not yet battle-tested. The recommended approach is committing normalized specs and running only generate in CI.
For pipelines where backend deploys before frontend, you can validate against live API endpoints:
npx intrig sync --all --ci
npx intrig generate --ci
npm run build
This syncs from live API endpoints, ensuring frontend builds against the deployed contract.
Requirements:
- Backend deployment completes before frontend CI runs
- API endpoints accessible from CI environment
- Pipeline orchestration to order builds correctly
Use case: Catch contract mismatches before frontend deployment when backend has already been updated.