Example - Prod_DBT_Deploy.yml

name: DBT_prod_deploy_workflow
 
# Controls when the action will run. 
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]
# Environment variable values are retrived from Github secrets
env:
  DBT_TARGET:            PROD
  DBT_SNOWFLAKE_ACCOUNT: ${{ secrets.DBT_SNOWFLAKE_ACCOUNT }}
  DBT_USER:              ${{ secrets.DBT_PROD_USER }}
  DBT_PASSWORD:          ${{ secrets.DBT_PROD_PASSWORD }}
  DBT_ROLE:              PROD_TRANSFORMER
  DBT_DB:                ONEDB
  DBT_SCHEMA:            EDM_AI
  DBT_WH:                PROD_TRANSFORMER_WH
 
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
 
    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      - name: Event info
        run: |
          echo This workflow on ${{ github.repository }} was started by ${{ github.actor }} from the event ${{ github.event_name }} and action ${{github.event.action}}
          
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - name: Checkout branch
        uses: actions/checkout@v3
 
      - name: Install Python 3.8
        uses: actions/setup-python@v4
        with:
          python-version: 3.8
 
      - name: Install DBT
        run: |
          python -m pip install --upgrade pip
          pip install dbt-snowflake==1.6.0
      - name: Install dbt dependency packages
        run: |
          dbt deps
      
      - name: Compile dbt models for this release
        run: |          
          dbt compile --model tag:serving+ --profiles-dir ./dbt_profiles
          
      - name: Deploy the models for this release
        run: |
          dbt run --full-refresh --model tag:serving tag:curated --vars '{"batch_name":"Dataops-Test-2"}' --profiles-dir ./dbt_profiles
         
name: DBT_prod_deploy_workflow
 
# Controls when the action will run. 
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]
# Environment variable values are retrived from Github secrets
env:
  DBT_TARGET:            PROD
  DBT_SNOWFLAKE_ACCOUNT: ${{ secrets.DBT_SNOWFLAKE_ACCOUNT }}
  DBT_USER:              ${{ secrets.DBT_PROD_USER }}
  DBT_PASSWORD:          ${{ secrets.DBT_PROD_PASSWORD }}
  DBT_ROLE:              PROD_TRANSFORMER
  DBT_DB:                ONEDB
  DBT_SCHEMA:            EDM_AI
  DBT_WH:                PROD_TRANSFORMER_WH
 
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
 
    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      - name: Event info
        run: |
          echo This workflow on ${{ github.repository }} was started by ${{ github.actor }} from the event ${{ github.event_name }} and action ${{github.event.action}}
          
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - name: Checkout branch
        uses: actions/checkout@v3
 
      - name: Install Python 3.8
        uses: actions/setup-python@v4
        with:
          python-version: 3.8
 
      - name: Install DBT
        run: |
          python -m pip install --upgrade pip
          pip install dbt-snowflake==1.6.0
      - name: Install dbt dependency packages
        run: |
          dbt deps
      
      - name: Compile dbt models for this release
        run: |          
          dbt compile --model tag:serving+ --profiles-dir ./dbt_profiles
          
      - name: Deploy the models for this release
        run: |
          dbt run --full-refresh --model tag:serving tag:curated --vars '{"batch_name":"Dataops-Test-2"}' --profiles-dir ./dbt_profiles