Sync plots to DB: main #1272
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: "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 |