githubgithub-actionsdbtgit-workflow

Sending vars in DBT run command using github actions


I am trying to run dbt core using github actions. I want to send vars as part of my dbt run command and I used the following yaml script:

name: schedule_dbt_jobs

on:
  pull_request:
    branches:    
      - develop

jobs:
  schedule_dbt_jobs:
    name: schedule_dbt_jobs
    runs-on: ubuntu-latest

    steps:
      - name: Check out
        uses: actions/checkout@master
      
      - uses: actions/setup-python@v1
        with:
          python-version: "3.7.x"
      
      - name: Install dependencies
        run: |
          pip install dbt
          dbt deps

      - name: Run dbt models
        run: dbt run --vars '{ic_schema: data_dev}'
      
      - name: Test dbt models
        run: dbt test

  

The above script is giving me an error in the line: run: dbt run --vars '{ic_schema: data_dev}'. I can see that, the error is due to having two : in the same line (i.e., run: and ic_schema:). Can someone help me by letting me know how I can send vars in the above dbt run command or someway to prevent this error.


Solution

  • I was able to solve this and felt like posting it, hoping it would help someone with a similar issue.

    I added a "" around the command and it worked for me. So I modified the command as below:

    - name: Run dbt models 
      run: "dbt run --vars '{ic_schema: data_dev}'"