Skip to content

This action lets you trigger a job run on dbt Cloud.

License

Notifications You must be signed in to change notification settings

b-per/dbt-cloud-job-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace
 
 

Repository files navigation

dbt Cloud action

Fork of https://github.com/fal-ai/dbt-cloud-action with additional capabilities as the original repo and action seem inactive.

This action lets you trigger a job run on dbt Cloud, fetches the run_results.json artifact, and git checkouts the branch that was ran by dbt Cloud.

Inputs

Credentials

  • dbt_cloud_url - dbt Cloud API URL (Default: https://cloud.getdbt.com)
  • dbt_cloud_token - dbt Cloud API token
  • dbt_cloud_account_id - dbt Cloud Account ID
  • dbt_cloud_job_id - dbt Cloud Job ID

We recommend passing sensitive variables as GitHub secrets. Example usage.

Action configuration

  • failure_on_error - Boolean to make the action report a failure when dbt-cloud runs. Mark this as false to run fal after the dbt-cloud job.
  • interval - The interval between polls in seconds (Default: 30)
  • get_artifacts - Whether run results, needed by fal, are fetched from dbt cloud. If using this action in other contexts this can be set to false, useful for jobs which do not generate artifacts.

dbt Cloud Job configuration

Use any of the documented options for the dbt API.

  • cause (Default: Triggered by a Github Action)
  • git_sha
  • git_branch
  • schema_override
  • dbt_version_override
  • threads_override
  • target_name_override
  • generate_docs_override
  • timeout_seconds_override
  • steps_override: pass a YAML-parseable string. (e.g. steps_override: '["dbt seed", "dbt run"]')

Examples

Trigger a job and override the steps

name: Run dbt Cloud job
on:
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: fal-ai/dbt-cloud-action@main
        id: dbt_cloud_job_run
        with:
          dbt_cloud_token: ${{ secrets.DBT_CLOUD_API_TOKEN }}
          dbt_cloud_account_id: ${{ secrets.DBT_CLOUD_ACCOUNT_ID }}
          dbt_cloud_job_id: ${{ secrets.DBT_CLOUD_JOB_ID }}
          failure_on_error: true
          steps_override: |
            - dbt build -s my_model+
            - dbt docs generate

Trigger a CI job previously created

This will trigger the CI job. If a new commit is pushed to the PR, the current job gets cancelled and a new one is created.

name: Run dbt Cloud CI job
on:
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: fal-ai/dbt-cloud-action@main
        id: dbt_cloud_ci_job_run
        with:
          dbt_cloud_token: ${{ secrets.DBT_CLOUD_API_TOKEN }}
          dbt_cloud_account_id: ${{ secrets.DBT_CLOUD_ACCOUNT_ID }}
          dbt_cloud_job_id: ${{ secrets.DBT_CLOUD_JOB_ID }}
          git_branch: ${{ github.head_ref }}
          target_name_override: dbt_pr_${{ github.event.pull_request.number }}
          cause: "CI job triggered from GH action"
          failure_on_error: true

About

This action lets you trigger a job run on dbt Cloud.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%