Skip to content

Commit

Permalink
set environment variables conditionally based on dispatch event (#63)
Browse files Browse the repository at this point in the history
abstract target to environment variable
use input variable for python version
  • Loading branch information
juls858 authored Oct 25, 2023
1 parent 709609f commit 3c297e7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
58 changes: 39 additions & 19 deletions .github/workflows/dbt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,64 @@ 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: |
pip install -r requirements.txt
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
Expand Down
2 changes: 1 addition & 1 deletion profiles.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
livequery:
target: dev
target: "{{ env_var('TARGET') }}"
outputs:
dev:
type: snowflake
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dbt-snowflake~=1.5
dbt-snowflake~=1.5.0

0 comments on commit 3c297e7

Please sign in to comment.