/

Loading...
Portfolio piece — no longer accepting signups. See what I'm building now
Automate DataChonk in your continuous integration and deployment pipelines for consistent, tested dbt model generation.
The recommended way to integrate DataChonk with GitHub repositories.
# .github/workflows/datachonk.yml
name: DataChonk Sync
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install DataChonk CLI
run: npm install -g @datachonk/cli
- name: Validate Chonks
run: datachonk validate --project-id ${{ secrets.DATACHONK_PROJECT_ID }}
env:
DATACHONK_API_KEY: ${{ secrets.DATACHONK_API_KEY }}
- name: Run dbt Tests
run: |
pip install dbt-snowflake
dbt deps
dbt test --select tag:datachonk# .github/workflows/schema-sync.yml
name: Schema Sync
on:
schedule:
- cron: '0 6 * * *' # Daily at 6 AM
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install DataChonk CLI
run: npm install -g @datachonk/cli
- name: Scan for Schema Changes
id: scan
run: |
datachonk scan --output json > scan_result.json
echo "changes=$(jq '.new_tables | length' scan_result.json)" >> $GITHUB_OUTPUT
env:
DATACHONK_API_KEY: ${{ secrets.DATACHONK_API_KEY }}
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }}
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
- name: Generate Staging Models
if: steps.scan.outputs.changes > 0
run: |
datachonk generate staging --auto
- name: Create Pull Request
if: steps.scan.outputs.changes > 0
uses: peter-evans/create-pull-request@v5
with:
title: 'chore: Auto-generated staging models'
body: |
DataChonk detected schema changes and generated new staging models.
Please review the generated SQL and tests.
branch: datachonk/auto-staging
labels: datachonk,auto-generated# .gitlab-ci.yml
stages:
- validate
- test
- deploy
variables:
DATACHONK_PROJECT_ID: $DATACHONK_PROJECT_ID
validate_chonks:
stage: validate
image: node:20
script:
- npm install -g @datachonk/cli
- datachonk validate
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
run_dbt_tests:
stage: test
image: python:3.11
script:
- pip install dbt-snowflake
- dbt deps
- dbt test --select tag:datachonk
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
sync_to_production:
stage: deploy
image: node:20
script:
- npm install -g @datachonk/cli
- datachonk push --env production
rules:
- if: $CI_COMMIT_BRANCH == "main"
environment:
name: production# .circleci/config.yml
version: 2.1
orbs:
node: circleci/node@5.1.0
jobs:
validate:
executor: node/default
steps:
- checkout
- run:
name: Install DataChonk CLI
command: npm install -g @datachonk/cli
- run:
name: Validate Chonks
command: datachonk validate
test:
docker:
- image: python:3.11
steps:
- checkout
- run:
name: Install dbt
command: pip install dbt-snowflake
- run:
name: Run Tests
command: |
dbt deps
dbt test --select tag:datachonk
workflows:
main:
jobs:
- validate
- test:
requires:
- validateConfigure these secrets in your CI/CD platform:
| Variable | Description | Required |
|---|---|---|
DATACHONK_API_KEY | Your DataChonk API key | Yes |
DATACHONK_PROJECT_ID | Project identifier | Yes |
SNOWFLAKE_ACCOUNT | Warehouse account (if scanning) | For scans |
SNOWFLAKE_USER | Warehouse username | For scans |
SNOWFLAKE_PASSWORD | Warehouse password | For scans |
GITHUB_TOKEN | For creating PRs | For auto-PRs |
The datachonk validate command performs these checks:
# datachonk.config.yml
validation:
require_tests: true
require_descriptions: true
naming:
staging_prefix: "stg_"
fact_prefix: "fct_"
dimension_prefix: "dim_"
forbidden_patterns:
- "SELECT *"
- "LIMIT 1000"Trigger CI pipelines from DataChonk events:
# Configure webhook in DataChonk settings
POST https://api.github.com/repos/your-org/dbt-project/dispatches
Headers:
Authorization: Bearer $GITHUB_TOKEN
Accept: application/vnd.github+json
Body:
{
"event_type": "datachonk_sync",
"client_payload": {
"project_id": "{{project_id}}",
"chonks_generated": "{{chonks_count}}"
}
}Security note: Never commit API keys or database credentials to your repository. Always use encrypted secrets provided by your CI/CD platform.