diff --git a/.github/workflows/dbt_run_deployment_template.yml b/.github/workflows/dbt_run_deployment_template.yml index 6e0bc79..ee5ebbb 100644 --- a/.github/workflows/dbt_run_deployment_template.yml +++ b/.github/workflows/dbt_run_deployment_template.yml @@ -20,6 +20,43 @@ on: jobs: + run_dbt_jobs: + runs-on: ubuntu-latest + environment: + name: ${{ inputs.environment }} + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v1 + with: + python-version: "3.7.x" + + - name: overwrite env vars + if: ${{ env.USE_VARS == 'TRUE' }} + run: | + echo "DBT_VERSION=${{ vars.DBT_VERSION }}" >> $GITHUB_ENV + echo "DBT_PROFILES_DIR=${{ vars.DBT_PROFILES_DIR }}" >> $GITHUB_ENV + echo "ACCOUNT=${{ vars.ACCOUNT }}" >> $GITHUB_ENV + echo "ROLE=${{ vars.ROLE }}" >> $GITHUB_ENV + echo "USER=${{ vars.USER }}" >> $GITHUB_ENV + echo "REGION=${{ vars.REGION }}" >> $GITHUB_ENV + echo "DATABASE=${{ vars.DATABASE }}" >> $GITHUB_ENV + echo "SCHEMA=${{ vars.SCHEMA }}" >> $GITHUB_ENV + + - name: install dependencies + run: | + pip3 install dbt-snowflake==${{ env.DBT_VERSION }} cli_passthrough requests click + dbt deps + - name: Run DBT Jobs + run: | + ${{ inputs.dbt_command }} + + - name: Run datashare model + run: | + cnt=$(dbt ls -m fsc_utils.datashare._datashare___create_gold | wc -l ); if [ $cnt -eq 1 ]; then dbt run -m fsc_utils.datashare._datashare___create_gold; fi; + dbt run-operation run_query --args "{sql: call admin.datashare.sp_grant_share_permissions('${{ env.DATABASE }}')}" + dbt: uses: ./.github/workflows/dbt.yml secrets: inherit