mirror of
https://github.com/FlipsideCrypto/analytics-workflow-templates.git
synced 2026-02-06 11:17:52 +00:00
70 lines
2.2 KiB
YAML
70 lines
2.2 KiB
YAML
name: dbt_run_deployment_template
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
dbt_command:
|
|
type: string
|
|
description: 'dbt commands to run'
|
|
required: true
|
|
environment:
|
|
type: string
|
|
description: 'github environment to get configuration values'
|
|
required: true
|
|
warehouse:
|
|
type: string
|
|
description: 'dbt warehouse'
|
|
required: true
|
|
|
|
env:
|
|
USE_VARS: "${{ vars.USE_VARS }}"
|
|
DBT_VERSION: "${{ vars.DBT_VERSION }}"
|
|
DBT_PROFILES_DIR: "${{ vars.DBT_PROFILES_DIR }}"
|
|
ACCOUNT: "${{ vars.ACCOUNT }}"
|
|
ROLE: "${{ vars.ROLE }}"
|
|
USER: "${{ vars.USER }}"
|
|
PASSWORD: "${{ secrets.PASSWORD }}"
|
|
REGION: "${{ vars.REGION }}"
|
|
DATABASE: "${{ vars.DATABASE }}"
|
|
SCHEMA: "${{ vars.SCHEMA }}"
|
|
|
|
WAREHOUSE: "${{ inputs.warehouse }}"
|
|
|
|
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 }}')}"
|