Skip to content

Commit

Permalink
Try new format for reading dbt commands from env vars in GitHub workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jeancochrane committed Aug 3, 2023
1 parent b26cefc commit 3ff6d98
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/build_and_test_dbt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,21 @@ jobs:
${{ env.CACHE_NAME }}-master
- if: ${{ steps.cache.outputs.cache-hit == 'true' }}
name: Set state args to build/test modified resources
run: echo "STATE_ARGS='-s state:modified --state target/'" >> "$GITHUB_ENV"
name: Set command args to build/test modified resources
run: |
{
echo "RUN_CMD='dbt run --target $TARGET -s state:modified --state target/'";
echo "TEST_CMD='dbt test --target $TARGET -s state:modified --state target/'";
} >> "$GITHUB_ENV"
shell: bash

- if: ${{ steps.cache.outputs.cache-hit != 'true' }}
name: Set state args to build/test all resources
run: echo "STATE_ARGS='--state target/'" >> "$GITHUB_ENV"
name: Set command args to build/test all resources
run: |
{
echo "RUN_CMD='dbt run --target $TARGET'";
echo "TEST_CMD='dbt test --target $TARGET'";
} >> "$GITHUB_ENV"
shell: bash

- name: Test dbt macros
Expand All @@ -77,11 +85,11 @@ jobs:
shell: bash

- name: Build models
run: dbt run --target "$TARGET" "$STATE_ARGS"
run: $RUN_CMD
working-directory: ${{ env.PROJECT_DIR }}
shell: bash

- name: Test models
run: dbt test --target "$TARGET" "$STATE_ARGS"
run: $TEST_CMD
working-directory: ${{ env.PROJECT_DIR }}
shell: bash

0 comments on commit 3ff6d98

Please sign in to comment.