name: dbt_run_deployment
run-name: dbt_run_deployment

on:
  workflow_dispatch:
    branches:
      - "main"
    inputs:
      warehouse:
        type: choice 
        description: Snowflake warehouse
        required: true 
        options:
          - DBT
          - DBT_CLOUD
          - DBT_EMERGENCY
        default: DBT
      dbt_command:
        type: string
        description: 'DBT Run Command'
        required: true

env:
  USE_VARS: "${{ vars.USE_VARS }}"
  DBT_PROFILES_DIR: "${{ vars.DBT_PROFILES_DIR }}"
  DBT_VERSION: "${{ vars.DBT_VERSION }}"
  ACCOUNT: "${{ vars.ACCOUNT }}"
  ROLE: "${{ vars.ROLE }}"
  USER: "${{ vars.USER }}"
  PASSWORD: "${{ secrets.PASSWORD }}"
  REGION: "${{ vars.REGION }}"
  DATABASE: "${{ vars.DATABASE }}"
  WAREHOUSE: "${{ inputs.WAREHOUSE }}"
  SCHEMA: "${{ vars.SCHEMA }}"

concurrency:
  group: ${{ github.workflow }}

jobs:
  called_workflow_template:
    uses: FlipsideCrypto/analytics-workflow-templates/.github/workflows/dbt_run_deployment_template.yml@main
    with:
      dbt_command: |
         ${{ inputs.dbt_command }}
      environment: workflow_prod
      warehouse: ${{ inputs.WAREHOUSE }}
    secrets: inherit 