Deploy compiled Lightdash projects to production or create new projects.
Compiles and deploys a Lightdash project to the active project or creates a new project.
lightdash deploy [options]Inherits all compilation options (see dbt Compilation), plus:
Project Creation:
--create [project_name] - Create new project (optional name; prompts if not provided in interactive mode)Deployment Options:
--ignore-errors - Deploy even with compilation errors (default: false)--start-of-week <number> - First day of week for date functions: 0 (Monday) to 6 (Sunday)--skip-dbt-compile - Skip dbt compile and deploy from existing ./target/manifest.json (default: false)--skip-warehouse-catalog - Skip fetch warehouse catalog and use types in yml (default: false)--use-dbt-list [true|false] - Use dbt list instead of dbt compile to generate manifest (default: true)--disable-timestamp-conversion [true|false] - Disable timestamp conversion to UTC for Snowflake warehouses (default: false)--no-warehouse-credentials - Create project without warehouse credentials (skips dbt compile and warehouse catalog)--organization-credentials <name> - Use organization warehouse credentials with specified name (Enterprise Edition feature)Usage Examples:
# Deploy to active project
lightdash deploy
# Deploy with model selection
lightdash deploy --select tag:production
# Create new project (interactive name prompt)
lightdash deploy --create
# Create new project with name
lightdash deploy --create "Production Analytics"
# Deploy with errors (force deployment)
lightdash deploy --ignore-errors
# Deploy with start of week setting
lightdash deploy --start-of-week 0 # Monday
# Deploy using dbt list (faster)
lightdash deploy --use-dbt-list true
# Deploy without warehouse credentials
lightdash deploy --no-warehouse-credentials
# Deploy with organization credentials
lightdash deploy --organization-credentials "prod-warehouse"
# Deploy with custom dbt directories
lightdash deploy --project-dir ./dbt --profiles-dir ./profiles
# CI/CD: Deploy with environment variables
export CI=true
export LIGHTDASH_API_KEY="token"
export LIGHTDASH_PROJECT="project-uuid"
lightdash deployWith --create flag:
Default behavior without --create:
# Requires: login and set-project completed
lightdash deployPrerequisites:
lightdash login)lightdash config set-project)Result:
With --create flag:
# Interactive mode: prompts for name
lightdash deploy --create
# Non-interactive: provide name
lightdash deploy --create "My New Project"
# CI mode: uses default name if not provided
export CI=true
lightdash deploy --createResult:
Note: Requires permission to create projects in organization.
Deploy inherits all compilation options. Common patterns:
# Deploy only production models
lightdash deploy --select tag:production
# Deploy specific models
lightdash deploy --select customers orders
# Deploy excluding test models
lightdash deploy --exclude test_*# Skip warehouse catalog (faster)
lightdash deploy --skip-warehouse-catalog
# Use existing manifest
lightdash deploy --skip-dbt-compile
# Skip both (fastest, for CI/CD)
lightdash deploy --no-warehouse-credentials# Custom dbt directories
lightdash deploy --project-dir ./dbt --profiles-dir ./profiles
# Custom target
lightdash deploy --target production
# dbt variables
lightdash deploy --vars '{"env": "prod"}'By default, deployment fails if compilation has errors:
# Default: fail on errors
lightdash deploy
# Error: Compilation failed - deployment abortedUse --ignore-errors to deploy anyway:
# Force deployment despite errors
lightdash deploy --ignore-errors
# Warning: Compilation had errors but deployment proceedingWhen to use --ignore-errors:
Risks:
Best practice: Fix errors rather than ignoring them.
Controls first day of week for week-related date functions:
--start-of-week <number>Values:
0 - Monday1 - Tuesday2 - Wednesday3 - Thursday4 - Friday5 - Saturday6 - SundayUsage:
# Set Monday as first day of week
lightdash deploy --start-of-week 0
# Set Sunday as first day of week
lightdash deploy --start-of-week 6Affects:
Default: If not specified, uses warehouse default or organization setting.
# Uses dbt list (faster)
lightdash deploy --use-dbt-list trueBehavior:
dbt list to identify modelsAdvantages:
# Uses dbt compile (thorough)
lightdash deploy --use-dbt-list falseBehavior:
dbt compileWhen to use:
Enterprise Edition feature for using shared warehouse credentials:
--organization-credentials <name>Usage:
# Use org credentials named "production-warehouse"
lightdash deploy --organization-credentials "production-warehouse"Benefits:
Requirements:
# Set authentication
export LIGHTDASH_API_KEY="your-service-account-token"
export LIGHTDASH_URL="https://app.lightdash.cloud"
export LIGHTDASH_PROJECT="project-uuid"
# Enable non-interactive mode
export CI=true
# Optional: dbt configuration
export DBT_PROJECT_DIR="./dbt"
export DBT_PROFILES_DIR="./profiles"#!/bin/bash
set -e
# Authenticate (token from environment)
echo "Deploying to Lightdash..."
# Deploy without warehouse credentials (CI/CD)
lightdash deploy \
--no-warehouse-credentials \
--ignore-errors \
--start-of-week 0
echo "Deployment complete!"name: Deploy to Lightdash
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install Lightdash CLI
run: npm install -g @lightdash/cli
- name: Deploy
env:
LIGHTDASH_API_KEY: ${{ secrets.LIGHTDASH_API_KEY }}
LIGHTDASH_PROJECT: ${{ secrets.LIGHTDASH_PROJECT }}
CI: true
run: lightdash deploy --no-warehouse-credentials# 1. Validate compilation locally
lightdash compile --verbose
# 2. Check for errors
echo $? # Should be 0
# 3. Deploy
lightdash deploy# Validate deployed project
lightdash validate --project project-uuid
# Check specific elements
lightdash validate --only tables chartsRequired permissions:
Required permissions:
Error if insufficient permissions:
ForbiddenError: You don't have permission to create projectsSolution: Contact organization admin for permission.
Exit Code 0: Deployment succeeded Exit Code 1: Deployment failed
Success Output:
✓ Compiled N models
✓ Deployed N explores
✓ Project URL: https://app.lightdash.cloud/projects/abc-123Error Output:
✗ Deployment failed: [error message]Error: "AuthorizationError"
lightdash loginError: "No active project set"
lightdash config set-projectError: "Compilation failed"
--verbose for details--ignore-errors to deploy anywayError: "ForbiddenError"
Error: "Could not connect to warehouse"
--no-warehouse-credentials for CI/CDCommit dbt models and YAML before deploying:
git add models/ dbt_project.yml
git commit -m "Update models"
git push
lightdash deployTest changes in preview before deploying to production:
# Create preview
lightdash preview --name test-feature
# Validate preview
lightdash validate --preview
# If good, deploy to production
lightdash deployTag production-ready models:
# dbt_project.yml
models:
my_project:
marts:
+tags: ["production"]Deploy only production models:
lightdash deploy --select tag:productionDeploy automatically on merge to main:
# .github/workflows/deploy.yml
on:
push:
branches: [main]
jobs:
deploy:
steps:
- run: lightdash deploy --no-warehouse-credentialsTrack deployment success:
# Deploy with verbose output
lightdash deploy --verbose 2>&1 | tee deploy.log
# Check exit code
if [ $? -eq 0 ]; then
echo "Deployment successful"
else
echo "Deployment failed"
exit 1
fi