# Add a GitHub Actions CI Job That Runs dbt build on Every Pull Request

Yes. An agent adds a CI job that installs dbt with the DuckDB adapter, seeds your sample data and runs dbt build on each pull request with no warehouse secret.

[Run this on Rush](https://cloud.getrush.ai/run/add-github-actions-ci/dbt/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent starts with what already runs on a pull request. In a project laid out like dbt-labs/jaffle-shop, `.github/workflows/ci.yml` has three jobs, one each for Snowflake, BigQuery and Postgres, and every one of them calls `.github/workflows/scripts/dbt_cloud_run_job.py` with `DBT_API_KEY` taken from `secrets.DBT_CLOUD_API_KEY`, a `DBT_PR_JOB_ID` and a schema override built from the head branch. `cd_prod.yml` and `cd_staging.yml` repeat the pattern on push. None of them runs dbt itself, so a contributor whose fork has no dbt Cloud secret gets no check, and a model that fails to compile is found by the Cloud job, after the pull request is open.

Then it reads what a local build needs. `dbt_project.yml` sets `require-dbt-version: ">=2.0.0"`, names the profile `default`, puts seeds under `seeds/jaffle-data` behind `var('load_source_data', false)` with `+schema: raw`, and materializes staging models as views and marts as tables. `macros/generate_schema_name.sql` sends seeds to a global `raw` schema and everything else to the target schema on a non-prod target, and `models/staging/__sources.yml` declares the `ecom` source in that `raw` schema with six tables, `raw_customers` through `raw_supplies`. `packages.yml` asks for `dbt-labs/dbt_utils` 1.4.1 and `dbt-audit-helper` from git, resolved by the committed `package-lock.yml`. `.gitignore` ignores `profiles.yml`, and `requirements.txt` holds pre-commit, requests and jafgen but no dbt: the README and `Taskfile.yml` install it separately.

Before writing any YAML the agent runs the build in its sandbox the way the job will: `python3 -m pip install uv` and `uv pip install --system` for `dbt-core` and `dbt-duckdb`, the same installer the existing jobs use for `requirements.txt`; a `profiles.yml` written to a directory the job points `DBT_PROFILES_DIR` at, with profile `default`, a `ci` target of type `duckdb` and a database file under the workspace; `dbt deps`; `dbt seed --vars '{"load_source_data": true}'`, which loads the six CSV files under `seeds/jaffle-data` into the `raw` schema; then `dbt build`, which runs the staging views, the marts and every test the YAML declares, such as the `not_null`, `unique` and `relationships` tests on `orders.yml` and the two `dbt_utils.expression_is_true` checks on order totals. `stg_orders.sql` goes through the cross-database `dbt.date_trunc` macro and the project's `cents_to_dollars`, so the agent reads the first run's log for any model that leans on a warehouse-specific function; one that fails on DuckDB is reported in the pull request, not patched.

Only then does it add a fourth job to `ci.yml`, `build_duckdb`, beside the three Cloud jobs: `actions/checkout`, `actions/setup-python` with the 3.12 the other jobs pin, the install and build commands above, `DBT_PROFILES_DIR` set as an env, and no secret at all. The seed step passes the same `--vars` so the source tables exist, and `dbt build` runs with `--fail-fast` off so the log shows every failing test rather than the first. The job runs on `ubuntu-latest`, not the `macos-latest` the Cloud jobs use, because nothing in it needs macOS. The three Cloud jobs are untouched: this job answers whether the project builds and its tests pass, and they still answer whether it does so on each warehouse.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add a GitHub Actions job that builds this dbt project on every pull request without a dbt Cloud secret. Read dbt_project.yml, packages.yml, package-lock.yml, macros/generate_schema_name.sql, models/staging/__sources.yml, requirements.txt, Taskfile.yml, .gitignore and every file under .github/workflows first. Install dbt-core and dbt-duckdb with uv the way the existing jobs install requirements.txt, write a profiles.yml for a DuckDB target in a directory the job names in DBT_PROFILES_DIR, run dbt deps, dbt seed with load_source_data set to true, and dbt build in the sandbox, and read the log for any model or test that fails on DuckDB. Then add one job to .github/workflows/ci.yml, next to the dbt Cloud jobs, that runs those same commands on ubuntu-latest with the Python version the other jobs pin. Leave the dbt Cloud jobs, the models and the seeds unchanged. Open a pull request whose description quotes the seed and build summaries from the sandbox run and names any model that did not build on DuckDB.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request that changes one file, `.github/workflows/ci.yml`, with a new `build_duckdb` job and nothing removed from the three Cloud jobs. Models, seeds, macros and `requirements.txt` are untouched. The description quotes the `dbt seed` summary and the `dbt build` summary from the sandbox run, the lines where dbt reports how many models, tests and seeds ran and how many passed, and lists any model that did not build on DuckDB with the error dbt printed.

The run's record keeps the full log: the `uv pip install` output with the dbt-core and dbt-duckdb versions it resolved under the `>=2.0.0` requirement, the `dbt deps` output showing `dbt_utils` and `audit_helper` installed from `package-lock.yml`, each seed's row count, and every test's pass or fail line. A reviewer can read that before the job has run once on GitHub.

Before merging, a reviewer checks the `DBT_PROFILES_DIR` path, decides whether the job should become a required status check on `main` and `staging`, and considers whether the profile's `threads` setting is worth raising. The agent does not make the job required and does not change branch protection; both are settings on the repository, and the description says so.

## Run it on every dbt project with no local CI job

A data team with several dbt repositories starts one run per repository from a script on its own server: `GET /o/{org}/github` lists every repository the installation reaches, the script clones each, looks for a `dbt_project.yml`, and calls `POST /o/{org}/sessions` with this body and that repository in `resources` only where no workflow under `.github/workflows/` runs `dbt build` or `dbt test`. Each call carries a `request_id` that is a UUID v5 of the repository's full name, so running the script twice returns the runs already started instead of starting them again.

Each run reads its own project. One with seeds behind a variable passes that variable; one with no seeds and only sources points the job at a sample database the project already ships; one whose `require-dbt-version` pins an older major installs an adapter release that satisfies it. The pull requests arrive one per repository, each with its own sandbox build in the record.

## Why run it on Rush?

A dbt CI job written without running it fails in ways that only show on the first pull request: an adapter that does not satisfy `require-dbt-version`, a profile that names the wrong schema so `generate_schema_name` sends seeds where the sources are not looking, a seed step that skips the sample data because the variable was not passed, or a model whose SQL compiles on Snowflake and not on DuckDB. In a Rush sandbox the agent installs the real adapter, loads the real CSV files and runs the real `dbt build`, and reads the log before it writes a line of YAML.

The seed and build summaries stay with the run and the pull request quotes them, so the reviewer reads evidence rather than a promise. A team with a dozen dbt projects starts a dozen runs at once, each with its own machine, its own DuckDB file and its own pull request, and reads the results as they arrive.

## Frequently asked questions

### Does this replace the dbt Cloud jobs?

No. The three Cloud jobs in `ci.yml` keep running against Snowflake, BigQuery and Postgres with the `DBT_CLOUD_API_KEY` secret. The new job sits beside them and needs no secret, so it also runs on a pull request from a fork, where the Cloud jobs cannot.

### Why DuckDB rather than a Postgres service container?

DuckDB runs in the job's process against a file, so the job needs no service, no port and no credentials, and the same commands run in the sandbox and on a laptop. A project that only compiles on one warehouse's SQL still has its Cloud job for that; the DuckDB job is the fast, secret-free check that the project parses, builds and passes its tests.

### Will the semantic models and metrics in the YAML break the build?

They are parsed, not run. `dbt build` compiles the semantic model and metric blocks that `orders.yml` and the other mart files embed, and the agent's first sandbox run shows whether the installed dbt-core release accepts that YAML spec under the project's `require-dbt-version`. If it does not, the pull request says which release the agent had to use.

### Does it change my models or seeds?

No. The job builds what is in the repository. A model that fails on DuckDB is named in the pull request with dbt's error so the team decides whether to make it cross-database or exclude it from this job with a selector; the agent does not edit SQL to get a green check.

### What about pre-commit and SQLFluff?

They are separate. `.pre-commit-config.yaml` runs ruff and the YAML and whitespace hooks, and the README notes that SQLFluff is left out because of the dbt Cloud IDE. The new job runs only dbt. Adding a pre-commit job to CI is a different change, and the agent does not fold it in.

## More dbt jobs

- [Add Model Contracts to a dbt Project](https://getrush.ai/run/add-model-contracts/dbt/)
- [Add Model Grants to a dbt Project](https://getrush.ai/run/add-model-grants/dbt/)
- [Add Model Groups and Access Levels to a dbt Project](https://getrush.ai/run/add-model-groups/dbt/)

## The same job on other stacks

- [Set Up GitHub Actions CI for an Eleventy Site](https://getrush.ai/run/add-github-actions-ci/eleventy/)
- [Set Up GitHub Actions CI for an Expo App](https://getrush.ai/run/add-github-actions-ci/expo/)
- [Set Up GitHub Actions CI for an Express App](https://getrush.ai/run/add-github-actions-ci/express/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
