Repository navigation
100 lines (87 loc) · 3.54 KB
/
Copy pathweekly_run.yml
File metadata and controls
100 lines (87 loc) · 3.54 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Weekly Production Analytics Run
# ==============================================================================
# DOCUMENTATION & PURPOSE
# ==============================================================================
# This workflow orchestrates the core production deployment of the Oppia
# Analytics dbt pipeline. It runs automatically every week to refresh production
# reporting datasets and can be triggered manually by the data team when needed.
#
# Environment Target: Production (oppia-analytics-prod)
# Key Operations:
# 1. Authenticates to GCP via Workload Identity Federation (short-lived OIDC).
# 2. Dynamically generates a BigQuery profile using ADC (method: oauth).
# 3. Runs data quality assertions and transforms fresh production analytics logs.
# ==============================================================================
on:
schedule:
# Runs at 00:00 UTC every Sunday
- cron: '0 0 * * 0'
workflow_dispatch:
# Allows the analytics team to trigger a one-off run manually from the GitHub UI
inputs:
full_refresh:
description: "Rebuild incremental tables from scratch (--full-refresh)"
type: boolean
default: false
concurrency:
group: weekly-production-run
cancel-in-progress: false
jobs:
dbt_run:
name: Execute dbt Production Pipeline
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout Code
uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: requirements.txt
- name: Install dbt and BigQuery Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# Authenticate via GCP Workload Identity Federation (scoped in GCP IAM to refs/heads/develop).
# Sets GOOGLE_APPLICATION_CREDENTIALS, which dbt's 'method: oauth' picks up via ADC.
- name: Authenticate to Google Cloud (WIF)
uses: google-github-actions/auth@v3
with:
project_id: oppia-analytics-prod
workload_identity_provider: ${{ secrets.GCP_PROD_WIF_PROVIDER }}
service_account: ${{ secrets.GCP_PROD_SERVICE_ACCOUNT }}
- name: Create dynamic profiles.yml for dbt
run: |
cat << 'EOF' > profiles.yml
oppia_analytics:
target: prod
outputs:
prod:
type: bigquery
method: oauth
project: oppia-analytics-prod
dataset: analytics_production
threads: 4
timeout_seconds: 300
location: US
EOF
- name: Verify dbt Connection
run: dbt debug --target prod --profiles-dir .
- name: Install dbt Packages (if any)
run: dbt deps --profiles-dir .
# Fail loudly if production GA4 exports have stalled rather than overwriting tables with 0 rows
- name: Check Source Freshness
run: dbt source freshness --target prod --profiles-dir .
- name: Execute and Test Pipeline
# 'dbt build' compiles, runs, and tests every staging, dim, fct, and agg table sequentially.
# If an upstream table fails a test, downstream tables are skipped to preserve data integrity.
run: |
if [ "${{ inputs.full_refresh }}" = "true" ]; then
dbt build --full-refresh --target prod --profiles-dir .
else
dbt build --target prod --profiles-dir .
fi