Giter Site home page Giter Site logo

dbt-cloud-action's Introduction

dbt Cloud action

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

Required

  • dbt_cloud_token - dbt Cloud API token
  • dbt_cloud_account_id - dbt Cloud Account ID
  • dbt_cloud_job_id - dbt Cloud Job ID

Optional

  • cause - Cause message to use (Default="Triggered by a GitHub Action")
  • git_sha - The git SHA (e.g. commit) to checkout before running dbt Cloud Job. This refers to the state your repository is when running. (dbt API docs)
  • interval - The interval between polls in seconds (Default=30)

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

Create your workflow

name: Run dbt cloud
on:
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: fal-ai/dbt-cloud-action@main
        id: dbt_cloud_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 }}

Use with fal

You can trigger a dbt Cloud run and it will download the artifacts to be able to run your fal run command easily in GitHub Actions.

You have to do certain extra steps described here:

name: Run dbt cloud and fal scripts
on:
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      # Checkout before downloading artifacts or setting profiles.yml
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - uses: fal-ai/dbt-cloud-action@main
        id: dbt_cloud_run
        with:
          dbt_cloud_token: ${{ secrets.DBT_CLOUD_API_TOKEN }}
          dbt_cloud_account_id: ${{ secrets.DBT_ACCOUNT_ID }}
          dbt_cloud_job_id: ${{ secrets.DBT_CLOUD_JOB_ID }}

      - name: Setup profiles.yml
        shell: python
        env:
          contents: ${{ secrets.PROFILES_YML }}
        run: |
          import yaml
          import os
          import io

          profiles_string = os.getenv('contents')
          profiles_data = yaml.safe_load(profiles_string)

          with io.open('profiles.yml', 'w', encoding='utf8') as outfile:
            yaml.dump(profiles_data, outfile, default_flow_style=False, allow_unicode=True)

      - uses: actions/setup-python@v2
        with:
          python-version: "3.9.x"

      - name: Install dependencies
        # Normally would install a `requirements.txt`.
        # This is to make it visible.
        run: |
          pip install dbt-bigquery
          pip install fal

      - name: Run fal scripts
        env:
          SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
          SLACK_BOT_CHANNEL: ${{ secrets.SLACK_BOT_CHANNEL }}
        run: |
          # Move to the same code state of the dbt Cloud Job
          git checkout ${{ steps.dbt_cloud_run.outputs.git_sha }}
          # TODO: review target in passed profiles.yaml contents
          fal run --profiles-dir .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.