Skip to main content

CI/CD Integration

Integrate CODITECT into your continuous integration and deployment workflows.

Supported Platforms

PlatformStatusFeatures
GitHub Actions✅ FullWorkflows, checks, deployments
GitLab CI✅ FullPipelines, environments
Jenkins✅ PartialBuild triggers
CircleCI✅ PartialWorkflows
Bitbucket Pipelines🔜 Coming-

GitHub Actions

Official Action

Use our official GitHub Action:

# .github/workflows/coditect.yml
name: CODITECT CI

on:
push:
branches: [main, develop]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup CODITECT
uses: coditect-ai/setup-coditect@v1
with:
api-key: ${{ secrets.CODITECT_API_KEY }}

- name: Run tests
run: coditect test

- name: Deploy preview
if: github.event_name == 'pull_request'
run: coditect deploy --preview

Action Inputs

InputRequiredDescription
api-keyYesCODITECT API key
versionNoCLI version (default: latest)
project-idNoProject ID (auto-detected from repo)

Action Outputs

OutputDescription
preview-urlURL of preview deployment
deployment-idUnique deployment identifier

Complete Workflow Example

name: CODITECT CI/CD

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
CODITECT_API_KEY: ${{ secrets.CODITECT_API_KEY }}

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: coditect-ai/setup-coditect@v1
with:
api-key: ${{ env.CODITECT_API_KEY }}
- run: coditect lint

test:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
- uses: coditect-ai/setup-coditect@v1
with:
api-key: ${{ env.CODITECT_API_KEY }}
- run: coditect test --coverage
- name: Upload coverage
uses: codecov/codecov-action@v3

preview:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: coditect-ai/setup-coditect@v1
with:
api-key: ${{ env.CODITECT_API_KEY }}
- name: Deploy preview
id: preview
run: |
url=$(coditect deploy --preview --json | jq -r '.url')
echo "url=$url" >> $GITHUB_OUTPUT
- name: Comment PR
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '🚀 Preview deployed: ${{ steps.preview.outputs.url }}'
})

deploy:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
environment: production
steps:
- uses: actions/checkout@v4
- uses: coditect-ai/setup-coditect@v1
with:
api-key: ${{ env.CODITECT_API_KEY }}
- run: coditect deploy --production

GitLab CI

Configuration

# .gitlab-ci.yml
stages:
- test
- preview
- deploy

variables:
CODITECT_API_KEY: $CODITECT_API_KEY

.coditect-setup: &coditect-setup
before_script:
- curl -fsSL https://get.coditect.ai/cli | bash
- export PATH="$HOME/.coditect/bin:$PATH"
- coditect auth login --token $CODITECT_API_KEY

test:
stage: test
<<: *coditect-setup
script:
- coditect test --coverage
coverage: '/Coverage: \d+\.\d+%/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml

preview:
stage: preview
<<: *coditect-setup
script:
- coditect deploy --preview
environment:
name: preview/$CI_MERGE_REQUEST_IID
url: $PREVIEW_URL
on_stop: stop_preview
only:
- merge_requests

stop_preview:
stage: preview
<<: *coditect-setup
script:
- coditect deploy --delete preview/$CI_MERGE_REQUEST_IID
environment:
name: preview/$CI_MERGE_REQUEST_IID
action: stop
when: manual
only:
- merge_requests

deploy_production:
stage: deploy
<<: *coditect-setup
script:
- coditect deploy --production
environment:
name: production
url: https://app.example.com
only:
- main
when: manual

Jenkins

Pipeline Configuration

// Jenkinsfile
pipeline {
agent any

environment {
CODITECT_API_KEY = credentials('coditect-api-key')
}

stages {
stage('Setup') {
steps {
sh 'curl -fsSL https://get.coditect.ai/cli | bash'
sh 'export PATH="$HOME/.coditect/bin:$PATH"'
}
}

stage('Test') {
steps {
sh 'coditect test'
}
}

stage('Deploy Preview') {
when {
changeRequest()
}
steps {
sh 'coditect deploy --preview'
}
}

stage('Deploy Production') {
when {
branch 'main'
}
steps {
input message: 'Deploy to production?'
sh 'coditect deploy --production'
}
}
}

post {
always {
sh 'coditect cleanup'
}
}
}

CLI Commands

Installation

# Install CLI
curl -fsSL https://get.coditect.ai/cli | bash

# Or with npm
npm install -g @coditect/cli

# Authenticate
coditect auth login --token YOUR_API_KEY

Common Commands

CommandDescription
coditect testRun tests
coditect lintRun linters
coditect buildBuild project
coditect deploy --previewDeploy preview
coditect deploy --productionDeploy to production
coditect deploy --delete IDDelete deployment

Command Options

# Test with coverage
coditect test --coverage --min-coverage 80

# Deploy with custom environment
coditect deploy --env staging --branch feature-x

# JSON output for scripting
coditect deploy --preview --json

API Integration

Trigger Deployment via API

curl -X POST https://api.coditect.ai/v1/deployments \
-H "Authorization: Bearer $CODITECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project_id": "proj_abc123",
"environment": "preview",
"ref": "feature-branch"
}'

Check Deployment Status

curl https://api.coditect.ai/v1/deployments/dep_xyz789 \
-H "Authorization: Bearer $CODITECT_API_KEY"

Deployment Webhooks

Receive notifications when deployments complete:

curl -X POST https://api.coditect.ai/v1/webhooks \
-H "Authorization: Bearer $CODITECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yourserver.com/webhooks/deploy",
"events": ["deployment.succeeded", "deployment.failed"]
}'

Best Practices

1. Use Secrets

Never commit API keys:

# GitHub
${{ secrets.CODITECT_API_KEY }}

# GitLab
$CODITECT_API_KEY (CI variable)

# Jenkins
credentials('coditect-api-key')

2. Preview on PRs

Always deploy previews for pull requests:

  • Enables visual review
  • Tests in realistic environment
  • Auto-cleanup on PR close

3. Production Gates

Add manual approval for production:

deploy:
environment:
name: production
when: manual # Require click to deploy

4. Parallel Jobs

Run independent jobs in parallel:

jobs:
lint:
...
test:
...
security:
...

# All run simultaneously, deploy waits for all
deploy:
needs: [lint, test, security]

5. Cache Dependencies

Speed up builds with caching:

- uses: actions/cache@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}