diff --git a/.github/workflows/dbt.yml b/.github/workflows/dbt.yml index 20381905..3d3acbf1 100644 --- a/.github/workflows/dbt.yml +++ b/.github/workflows/dbt.yml @@ -20,35 +20,29 @@ on: env: DBT_PROFILES_DIR: ./ - ACCOUNT: "${{ vars.ACCOUNT }}" - ROLE: "${{ vars.ROLE }}" - USER: "${{ vars.USER }}" - PASSWORD: "${{ secrets.PASSWORD }}" - REGION: "${{ vars.REGION }}" - DATABASE: "${{ vars.DATABASE }}" - WAREHOUSE: "${{ vars.WAREHOUSE }}" - SCHEMA: "${{ vars.SCHEMA }}" + ACCOUNT: ${{ vars.ACCOUNT }} + ROLE: ${{ vars.ROLE }} + USER: ${{ vars.USER }} + PASSWORD: ${{ secrets.PASSWORD }} + REGION: ${{ vars.REGION }} + DATABASE: ${{ vars.DATABASE }} + WAREHOUSE: ${{ vars.WAREHOUSE }} + SCHEMA: ${{ vars.SCHEMA }} + TARGET: ${{ vars.TARGET }} jobs: - dbt: + dispatched: + if: github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest env: - DBT_PROFILES_DIR: ./ - ACCOUNT: "${{ vars.ACCOUNT }}" - ROLE: "${{ vars.ROLE }}" - USER: "${{ vars.USER }}" - PASSWORD: "${{ secrets.PASSWORD }}" - REGION: "${{ vars.REGION }}" - DATABASE: "${{ vars.DATABASE }}" WAREHOUSE: ${{ inputs.warehouse }} - SCHEMA: "${{ vars.SCHEMA }}" environment: name: ${{ inputs.environment }} steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: ${{ inputs.python_version }} cache: "pip" - name: install dependencies run: | @@ -56,8 +50,34 @@ jobs: dbt deps - name: Run DBT Jobs run: | - dbt ${{ inputs.command }} --target ${{ inputs.environment }} + ${{ inputs.command }} - name: Store logs + uses: actions/upload-artifact@v3 + with: + name: dbt-logs + path: | + logs + target + not_dispatched: + if: github.event_name != 'workflow_dispatch' + runs-on: ubuntu-latest + environment: + name: ${{ inputs.environment }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.python_version }} + cache: "pip" + - name: install dependencies + run: | + pip install -r requirements.txt + dbt deps + - name: Run DBT Jobs + run: | + ${{ inputs.command }} + - name: Store logs + if: always() uses: actions/upload-artifact@v3 with: name: dbt-logs diff --git a/profiles.yml b/profiles.yml index 5d3c4d4b..bdb71c2f 100644 --- a/profiles.yml +++ b/profiles.yml @@ -1,5 +1,5 @@ livequery: - target: dev + target: "{{ env_var('TARGET') }}" outputs: dev: type: snowflake diff --git a/requirements.txt b/requirements.txt index fefc66cd..ff8e7ca3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -dbt-snowflake~=1.5 \ No newline at end of file +dbt-snowflake~=1.5.0 \ No newline at end of file