Skip to content

test-dbt-source-freshness #514

test-dbt-source-freshness

test-dbt-source-freshness #514

name: test-dbt-source-freshness
on:
workflow_dispatch:
schedule:
# Every day at 8am (2pm UTC-5)
- cron: '0 13 * * *'
jobs:
test-dbt-source-freshness:
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint
# so that we can authenticate with AWS
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup dbt
uses: ./.github/actions/setup_dbt
with:
role-to-assume: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }}
- name: Test source freshness
run: dbt source freshness --target "$TARGET"
working-directory: ${{ env.PROJECT_DIR }}
shell: bash
- name: Get current time
if: failure()
run: echo "TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%S")" >> "$GITHUB_ENV"
shell: bash
# Only publish to SNS on failure for scheduled runs, since other event
# types should notify the GitHub user who triggered the event
- name: Send failure notification
if: github.event_name == 'schedule' && failure()
uses: ./.github/actions/publish_sns_topic
with:
sns_topic_arn: ${{ secrets.AWS_SNS_NOTIFICATION_TOPIC_ARN }}
subject: "dbt source freshness tests failed for workflow run: ${{ github.run_id }}"
body: |
dbt source freshness tests failed for workflow ${{ github.run_id }}, run on ${{ env.TIMESTAMP }} UTC
Link to failing workflow:
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}