Skip to content

dagucloud/dbt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dbt

Official Dagu action for running dbt Core commands with uv.

This action keeps dbt and adapter packages out of the Dagu core binary and worker image. The action pins uv with Dagu tools; each invocation installs the requested dbt Python requirements into an isolated uv run environment.

Usage

type: graph

steps:
  - id: dbt_build
    action: dbt@v1
    with:
      projectDir: /data/jaffle-shop
      profilesDir: /data/dbt-profiles
      requirements:
        - dbt-duckdb==1.10.1
      command: build
      target: prod
      select:
        - tag:nightly
      targetPath: ${DAG_RUN_ARTIFACTS_DIR}/dbt-target

  - id: print_summary
    depends: [dbt_build]
    run: |
      echo "dbt exit code: ${dbt_build.outputs.exitCode}"
      echo "dbt run results: ${dbt_build.outputs.runResultsPath}"

projectDir must point to the directory containing dbt_project.yml on the worker that runs the action. Remote actions run in their own action workspace, so pass an absolute path or a path that is meaningful on that worker.

Commands

The command input defaults to build.

Supported commands:

Command Notes
build Runs models, tests, snapshots, seeds, and supported functions in DAG order.
run Runs selected models.
test Runs tests.
seed Loads seed CSV files.
snapshot Runs snapshots.
compile Compiles project SQL without running models.
deps Installs dbt package dependencies.
debug Checks project and connection configuration.
parse Parses the project and writes artifacts.
list / ls Lists project resources.
show Previews rows for a selected resource.
run-operation Invokes a macro. Pass the macro name in args.
source freshness Checks source freshness.
docs generate Generates dbt docs artifacts.
clean Deletes dbt-generated artifacts.

Examples:

steps:
  - id: deps
    action: dbt@v1
    with:
      projectDir: /data/jaffle-shop
      requirements:
        - dbt-duckdb==1.10.1
      command: deps

  - id: changed_models
    action: dbt@v1
    with:
      projectDir: /data/jaffle-shop
      profilesDir: /data/dbt-profiles
      requirements:
        - dbt-duckdb==1.10.1
      command: build
      select:
        - state:modified+
      state: /data/dbt-state
      defer: true

Python Requirements

Use requirements for pip-compatible dbt packages.

The default is:

requirements:
  - dbt-core

Most real projects need an adapter package. Pin exact package versions for production workflows:

requirements:
  - dbt-duckdb==1.10.1

If the adapter already pins a compatible dbt-core, you can provide only the adapter:

requirements:
  - dbt-postgres==1.9.0

For private package indexes or credentials, pass the relevant uv or pip environment variables through env, such as UV_INDEX, UV_DEFAULT_INDEX, or UV_INDEX_URL.

Profiles and Secrets

Use profilesDir when profiles.yml is outside the dbt project:

steps:
  - id: dbt_run
    action: dbt@v1
    with:
      projectDir: /srv/dbt/project
      profilesDir: /srv/dbt/profiles
      requirements:
        - dbt-postgres==1.9.0
      command: run
      target: prod
      env:
        DBT_ENV_SECRET_PASSWORD: ${DBT_ENV_SECRET_PASSWORD}

The action passes env values only to the dbt process. Secrets are still governed by the Dagu worker environment and Dagu secret masking.

Selection and Flags

Structured inputs map to common dbt flags:

steps:
  - id: dbt_build
    action: dbt@v1
    with:
      projectDir: /srv/dbt/project
      profilesDir: /srv/dbt/profiles
      requirements:
        - dbt-bigquery==1.10.0
      command: build
      target: prod
      select:
        - tag:nightly
        - path:models/marts
      exclude:
        - config.materialized:incremental
      vars:
        run_started_by: dagu
      threads: 4
      failFast: true

Use args for command-specific flags that do not have a first-class input:

steps:
  - id: vacuum
    action: dbt@v1
    with:
      projectDir: /srv/dbt/project
      profilesDir: /srv/dbt/profiles
      requirements:
        - dbt-postgres==1.9.0
      command: run-operation
      args:
        - vacuum_table
        - --args
        - '{"relation": "analytics.events"}'

Artifacts

The action captures dbt stdout/stderr into structured outputs and mirrors them to the step log. It also reports known dbt artifact paths when those files exist:

Output Description
manifestPath Path to manifest.json under targetPath.
runResultsPath Path to run_results.json under targetPath.
catalogPath Path to catalog.json under targetPath.
sourcesPath Path to sources.json under targetPath.

Set targetPath under ${DAG_RUN_ARTIFACTS_DIR} when you want dbt artifacts to be stored with the DAG run:

steps:
  - id: dbt_docs
    action: dbt@v1
    with:
      projectDir: /srv/dbt/project
      profilesDir: /srv/dbt/profiles
      requirements:
        - dbt-duckdb==1.10.1
      command: docs generate
      targetPath: ${DAG_RUN_ARTIFACTS_DIR}/dbt-target
      logPath: ${DAG_RUN_ARTIFACTS_DIR}/dbt-logs

targetPath defaults to ${DAG_RUN_WORK_DIR}/dbt-target when that runtime variable is available. logPath defaults to ${DAG_RUN_WORK_DIR}/dbt-logs.

Inputs

Field Required Default Description
projectDir Yes - Directory containing dbt_project.yml.
command No build dbt command to run.
requirements No ["dbt-core"] Pip requirement specifiers installed with uv run --with.
profilesDir No - Directory containing profiles.yml.
profile No - dbt profile name.
target No - dbt target name.
select No - List of --select arguments.
exclude No - List of --exclude arguments.
selector No - YAML selector name passed with --selector.
vars No - Value passed with --vars. Objects are encoded as compact JSON.
threads No - Thread count passed with --threads.
state No - State directory passed with --state.
targetPath No run work dir Directory passed with --target-path.
logPath No run work dir Directory passed with --log-path.
fullRefresh No false Pass --full-refresh.
failFast No false Pass --fail-fast.
warnError No false Pass --warn-error.
defer No false Pass --defer.
quiet No false Pass --quiet.
args No [] Additional raw dbt CLI arguments appended after structured options.
env No - Extra environment variables exposed to the dbt process.
pythonVersion No 3.13.9 Python version used by uv for the dbt process.
timeoutSeconds No 3600 Timeout for the dbt process.

Outputs

Field Description
ok true when dbt exits with code 0.
exitCode dbt process exit code.
command Full argv used to invoke dbt through uv.
stdout dbt stdout.
stderr dbt stderr.
durationMs Wrapper-measured dbt process duration in milliseconds.
targetPath Effective dbt target path.
logPath Effective dbt log path.
manifestPath Present when manifest.json exists.
runResultsPath Present when run_results.json exists.
catalogPath Present when catalog.json exists.
sourcesPath Present when sources.json exists.
error Validation or wrapper error object when the wrapper fails before dbt runs.

If dbt exits non-zero, the action step fails after writing the structured output payload.

Local Development

Use source: to call a local checkout:

steps:
  - id: dbt_build
    action: source:file:///path/to/dbt@local
    with:
      projectDir: /tmp/jaffle-shop
      requirements:
        - dbt-duckdb==1.10.1
      command: build

Security

This action is not a sandbox. dbt runs with the same worker permissions, filesystem access, network access, and secrets available to the Dagu worker process. Only run trusted dbt projects and packages.

Package Layout

dagu-action.yaml
workflow.yaml
scripts/
  run_dbt.py
examples/
  basic.yaml

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages