Weekly Supabase → BigQuery mirror #12
This file contains hidden or 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
| name: Weekly Supabase → BigQuery mirror | |
| # Mirrors Supabase tables (users, recommendation_log, feedback, groups, | |
| # group_members, group_votes) into the `plot_supabase_mirror` BigQuery | |
| # dataset. Full refresh, every Monday 08:00 UTC (after the retrain run | |
| # at 07:00). | |
| # | |
| # Why: gives us a queryable BQ copy for analytics + a belt-and-suspenders | |
| # backup against accidental drops on Supabase. | |
| # | |
| # Required GH Actions secrets (you already have them): | |
| # GCP_SA_KEY — service-account JSON with bigquery.dataEditor + jobUser | |
| # on the project | |
| # GCP_PROJECT — mlops-project-491402 | |
| # DATABASE_URL — Supabase pooler connection string | |
| on: | |
| schedule: | |
| - cron: "0 8 * * 1" | |
| workflow_dispatch: | |
| jobs: | |
| mirror: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: pip | |
| cache-dependency-path: requirements.txt | |
| - name: Install deps | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Auth to GCP | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| - name: Run mirror | |
| env: | |
| GCP_PROJECT: ${{ secrets.GCP_PROJECT }} | |
| DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
| BQ_BACKUP_DATASET: plot_supabase_mirror | |
| BQ_BACKUP_LOCATION: US | |
| run: python scripts/supabase_to_bq.py | tee mirror_log.txt | |
| - name: Summarize | |
| if: always() | |
| run: | | |
| { | |
| echo "## Supabase → BigQuery mirror" | |
| echo "" | |
| echo '```' | |
| grep -E "rows mirrored|Done\." mirror_log.txt || true | |
| echo '```' | |
| } >> "$GITHUB_STEP_SUMMARY" |