-
Notifications
You must be signed in to change notification settings - Fork 4
64 lines (54 loc) · 2.07 KB
/
build_daily_dbt_models.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: build-daily-dbt-models
on:
workflow_dispatch:
schedule:
# Every day at 8am (2pm UTC-5)
- cron: '0 12 * * *'
jobs:
build-daily-dbt-models:
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 }}
role-duration-seconds: 14400 # Worst-case time for full build
- name: Restore dbt state cache
id: cache
uses: ./.github/actions/restore_dbt_cache
with:
path: ${{ env.PROJECT_DIR }}/${{ env.STATE_DIR }}
key: ${{ env.CACHE_KEY }}
- name: Deploy model dependencies
run: ../.github/scripts/deploy_dbt_model_dependencies.sh
working-directory: ${{ env.PROJECT_DIR }}
shell: bash
- name: Build daily models
run: dbt run -t "$TARGET" -s tag:daily --defer --state "$STATE_DIR"
working-directory: ${{ env.PROJECT_DIR }}
shell: bash
- name: Test daily models
run: dbt test -t "$TARGET" -s tag:daily --defer --state "$STATE_DIR"
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
- name: Send failure notification
if: failure()
uses: ./.github/actions/publish_sns_topic
with:
sns_topic_arn: ${{ secrets.AWS_SNS_NOTIFICATION_TOPIC_ARN }}
subject: "Daily dbt model creation failed for workflow run: ${{ github.run_id }}"
body: |
Daily dbt model creation 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 }}