-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (71 loc) · 2.71 KB
/
sync-postgres.yml
File metadata and controls
83 lines (71 loc) · 2.71 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
name: "Sync: PostgreSQL"
run-name: "Sync plots to DB: ${{ github.ref_name }}"
# Syncs plots from main branch to PostgreSQL.
# This ensures the database only contains data for code that is actually in main.
#
# New structure: plots/{spec_id}/
# - spec.md: Spec description, data requirements, use cases
# - metadata.yaml: Tags, implementation metadata, generation history
# - implementations/{library}.py: Library-specific implementation code
on:
push:
branches:
- main
paths:
- 'plots/**'
workflow_dispatch: # Allow manual trigger
concurrency:
group: sync-postgres
cancel-in-progress: false # Queue instead of cancel
jobs:
sync:
name: Sync to PostgreSQL
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: |
uv sync
- name: Setup GCP authentication
uses: google-github-actions/auth@v3
with:
credentials_json: ${{ secrets.GCS_CREDENTIALS }}
- name: Run database migrations
run: |
uv run alembic upgrade head
env:
INSTANCE_CONNECTION_NAME: ${{ secrets.INSTANCE_CONNECTION_NAME }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASS: ${{ secrets.DB_PASS }}
DB_NAME: ${{ secrets.DB_NAME }}
- name: Sync plots to database
run: |
uv run python automation/scripts/sync_to_postgres.py
env:
INSTANCE_CONNECTION_NAME: ${{ secrets.INSTANCE_CONNECTION_NAME }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASS: ${{ secrets.DB_PASS }}
DB_NAME: ${{ secrets.DB_NAME }}
GCS_BUCKET: ${{ vars.GCS_BUCKET || 'pyplots-images' }}
- name: Summary
run: |
echo "### Sync Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Plots have been synced to PostgreSQL." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Structure synced:**" >> $GITHUB_STEP_SUMMARY
echo "- plots/{spec-id}/specification.md (descriptions, applications, data, notes)" >> $GITHUB_STEP_SUMMARY
echo "- plots/{spec-id}/specification.yaml (tags, created, issue, suggested, history)" >> $GITHUB_STEP_SUMMARY
echo "- plots/{spec-id}/metadata/{library}.yaml (per-library metadata)" >> $GITHUB_STEP_SUMMARY
echo "- plots/{spec-id}/implementations/*.py (code)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Trigger:** \`${{ github.event_name }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY