Run your dbt Cloud production job on every merge to main

By General Input

Every time a pull request merges into main, we kick off your dbt Cloud production job so your warehouse always reflects the exact code that just shipped.

Integrations

  • dbt Cloud
  • GitHub

Type

Deterministic Code

Categories

  • Engineering
  • Operations

Whenever a pull request is merged into the default branch (main) of my GitHub repository, run my dbt Cloud production deployment job so the warehouse rebuilds from exactly the code that just landed. This is a deterministic code workflow: one GitHub merge comes in, one dbt Cloud run goes out, with no branching logic.

Trigger on GitHub pull request webhooks. Only proceed when the pull request was actually merged into main: the event is a pull_request event whose action is closed, whose merged flag is true, and whose base branch is the repository's default branch (main). Ignore pull requests that were closed without merging, and ignore merges into any other branch, so the job only runs on genuine deployments to main.

When a qualifying merge fires, call the dbt Cloud Trigger Job Run operation to kick off the configured production job, using the dbt Cloud account id and the production job id. Pass a cause message that references the merged pull request number and the merged commit SHA, for example 'Deploy: merged PR #<number> at <commit sha>', so every run is traceable back to the change that triggered it.

Pin the run to the merged code by passing the merged commit SHA as the run's git_sha override (the pull request's merge commit SHA), and optionally set git_branch to main, so dbt Cloud builds exactly that commit rather than whatever happens to be latest on the branch. Trigger the run and finish; there is no follow-up polling or notification step.

Related prompts

Explore more prompts
Open a Heroku release war room the moment production looks wrongSee what Hacker News really thinks of the tools in your stackSee and fix Terraform variable drift across every workspaceA docs coverage board that catches what shipped undocumentedA technology radar board your architecture group works out ofTake-home review desk that runs candidate code in a sandboxDeploy control room for DigitalOcean App Platform appsClean up the Fly.io preview apps your team left behindA searchable data catalog your business teams actually openFind the dbt models that are burning your warehouse budget