From db56fe2a31b944db2e1810d1debf68e0ea3798de Mon Sep 17 00:00:00 2001 From: Julius Remigio <14811322+juls858@users.noreply.github.com> Date: Mon, 21 Aug 2023 11:13:06 -0700 Subject: [PATCH] Cleanup Workflows (#42) --- .github/workflows/dbt.yml | 10 ++++- .github/workflows/dbt_run_adhoc.yml | 46 ++++------------------- .github/workflows/dbt_run_dev_refresh.yml | 39 +++---------------- .github/workflows/dbt_test.yml | 4 +- 4 files changed, 24 insertions(+), 75 deletions(-) diff --git a/.github/workflows/dbt.yml b/.github/workflows/dbt.yml index 8b0fbaf..38f22a9 100644 --- a/.github/workflows/dbt.yml +++ b/.github/workflows/dbt.yml @@ -3,8 +3,9 @@ on: workflow_call: inputs: warehouse: - required: true + required: false type: string + default: DBT_CLOUD environment: required: true type: string @@ -56,3 +57,10 @@ jobs: - name: Run DBT Jobs run: | dbt ${{ inputs.command }} + - name: Store logs + uses: actions/upload-artifact@v3 + with: + name: dbt-logs + path: | + logs + target \ No newline at end of file diff --git a/.github/workflows/dbt_run_adhoc.yml b/.github/workflows/dbt_run_adhoc.yml index 0faaa4f..2d02088 100644 --- a/.github/workflows/dbt_run_adhoc.yml +++ b/.github/workflows/dbt_run_adhoc.yml @@ -26,46 +26,14 @@ on: description: 'DBT Run Command' required: true -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 }}" - concurrency: group: ${{ github.workflow }} jobs: - run_dbt_jobs: - runs-on: ubuntu-latest - environment: - name: workflow_${{ inputs.environment }} - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: "pip" - - - - name: install dependencies - run: | - pip install -r requirements.txt - dbt deps - - name: Run DBT Jobs - run: | - dbt ${{ inputs.dbt_command }} - - - name: Store logs - uses: actions/upload-artifact@v3 - with: - name: dbt-logs - path: logs \ No newline at end of file + ad_hoc: + uses: ./.github/workflows/dbt.yml + secrets: inherit + with: + warehouse: ${{ inputs.warehouse }} + environment: workflow_${{ inputs.environment }} + command: ${{ inputs.dbt_command }} \ No newline at end of file diff --git a/.github/workflows/dbt_run_dev_refresh.yml b/.github/workflows/dbt_run_dev_refresh.yml index 6d357f6..23f791d 100644 --- a/.github/workflows/dbt_run_dev_refresh.yml +++ b/.github/workflows/dbt_run_dev_refresh.yml @@ -7,40 +7,13 @@ on: # Runs "at 9:00 UTC" (see https://crontab.guru) - cron: '0 9 * * *' -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 }}" - concurrency: group: ${{ github.workflow }} jobs: - run_dbt_jobs: - runs-on: ubuntu-latest - environment: - name: workflow_prod - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: "pip" - - - - name: install dependencies - run: | - pip install -r requirements.txt - dbt deps - - name: Run DBT Jobs - run: | - dbt run-operation run_sp_create_prod_clone \ No newline at end of file + dev_refresh: + uses: ./.github/workflows/dbt.yml + secrets: inherit + with: + environment: workflow_prod + command: run-operation run_sp_create_prod_clone \ No newline at end of file diff --git a/.github/workflows/dbt_test.yml b/.github/workflows/dbt_test.yml index 421dbea..068cac6 100644 --- a/.github/workflows/dbt_test.yml +++ b/.github/workflows/dbt_test.yml @@ -27,7 +27,7 @@ concurrency: group: ${{ github.workflow }} jobs: - scheduled_job: + scheduled: uses: ./.github/workflows/dbt.yml if: github.event_name == 'schedule' || github.event_name == 'push' secrets: inherit @@ -36,7 +36,7 @@ jobs: environment: workflow_${{ inputs.environment }} command: test --selector test_udfs - manual_job: + dispached: uses: ./.github/workflows/dbt.yml if: github.event_name == 'workflow_dispatch' secrets: inherit