Update Dashboard Data #78
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: Update Dashboard Data | |
| on: | |
| # VPS pipeline triggers this after completing | |
| repository_dispatch: | |
| types: [pipeline-complete] | |
| # Safety net: run daily at 04:30 UTC (pipeline starts at 03:00) | |
| schedule: | |
| - cron: "30 4 * * *" | |
| # Manual trigger | |
| workflow_dispatch: | |
| jobs: | |
| export-data: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout gh-pages branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install Python dependencies | |
| run: pip install psycopg2-binary numpy pandas statsmodels scipy | |
| - name: Checkout export scripts from main | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: master | |
| path: _src | |
| sparse-checkout: | | |
| scripts/export_redlines_data.py | |
| scripts/export_analytics_data.py | |
| - name: Run redlines export | |
| env: | |
| DB_HOST: ${{ secrets.DB_HOST }} | |
| DB_PORT: ${{ secrets.DB_PORT }} | |
| DB_USER: ${{ secrets.DB_USER }} | |
| DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| run: | | |
| cd _src | |
| mkdir -p public/data | |
| python scripts/export_redlines_data.py | |
| cp public/data/*.json ../data/ | |
| - name: Run analytics export | |
| env: | |
| DB_HOST: ${{ secrets.DB_HOST }} | |
| DB_PORT: ${{ secrets.DB_PORT }} | |
| DB_USER: ${{ secrets.DB_USER }} | |
| DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| run: | | |
| cd _src | |
| python scripts/export_analytics_data.py | |
| cp public/data/analytics_*.json ../data/ | |
| - name: Commit and push if data changed | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add data/ | |
| if git diff --cached --quiet; then | |
| echo "No data changes detected." | |
| else | |
| git commit -m "Auto-update data $(date -u '+%Y-%m-%d %H:%M') UTC" | |
| git push | |
| fi |