Merge pull request #54 from dpguthrie/new-branch #97
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This action will trigger an already created job on dbt Cloud | |
# The important settings for the job include: | |
# - defer - defer this job to itself (will always refer to the most recently modified version of production) | |
# - commands - ensure you're using the state:modified+ selector to only run what's been modified | |
# since the last successful run for the job you're deferring to | |
name: Run Job on Merge | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
run_on_merge: | |
runs-on: ubuntu-latest | |
env: | |
DBT_CLOUD_SERVICE_TOKEN: ${{ secrets.DBT_CLOUD_SERVICE_TOKEN }} | |
DBT_CLOUD_ACCOUNT_ID: 43786 | |
JOB_ID: 384691 | |
METABASE_USER: ${{ secrets.METABASE_USER }} | |
METABASE_PASSWORD: ${{ secrets.METABASE_PASSWORD }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: "3.9.x" | |
- name: Install dependencies | |
run: pip install dbtc==0.8.0 dbt-metabase | |
- name: Run Merge Job | |
run: | | |
run=$(dbtc trigger-job \ | |
--job-id=$JOB_ID \ | |
--payload='{"cause": "Merging code to main"}') | |
echo "RUN_ID=$(echo $run | jq '.data.id')" >> $GITHUB_ENV | |
- name: Get Manifest | |
run: | | |
dbtc -o manifest.json get-run-artifact \ | |
--run-id=$RUN_ID \ | |
--path=manifest.json | |
- name: Extract Metabase Exposures | |
run: | | |
dbt-metabase exposures \ | |
--dbt_manifest_path manifest.json \ | |
--dbt_database DOUG_DEMO_V2 \ | |
--metabase_host metabase-production-2dd8.up.railway.app \ | |
--metabase_user $METABASE_USER \ | |
--metabase_password $METABASE_PASSWORD \ | |
--metabase_database SNOWFLAKE \ | |
--output_path ./models/marts/exposures/ \ | |
--output_name metabase_exposures \ | |
--metabase_sync_skip | |
- name: Add file | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: '*.yml' | |
committer_name: Github Actions | |
committer_email: [email protected] | |
message: 'Add metabase exposures' | |
- name: Run Merge Job Again (to update Explorer) | |
run: | | |
run=$(dbtc trigger-job \ | |
--job-id=$JOB_ID \ | |
--payload='{"cause": "Merging code to main"}' \ | |
--no-should-poll) |