name: Keep HF Space Alive on: schedule: - cron: '0 5 * * *' # Daily at 05:00 UTC workflow_dispatch: # Allow manual trigger permissions: contents: write jobs: heartbeat: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install pandas run: pip install pandas - name: Refresh FRED demo data continue-on-error: true # Don't break heartbeat if FRED is down run: python scripts/download_fred_data.py - name: Generate heartbeat CSV run: | APP_LIVE_DATE="2026-02-11" TODAY=$(date -u +%Y-%m-%d) DAYS=$(( ( $(date -u -d "$TODAY" +%s) - $(date -u -d "$APP_LIVE_DATE" +%s) ) / 86400 )) echo "date,days_since_app_went_live" > data/heartbeat.csv echo "${TODAY},${DAYS}" >> data/heartbeat.csv cat data/heartbeat.csv - name: Commit and push to GitHub run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add data/ git diff --staged --quiet || git commit -m "Daily heartbeat + FRED refresh: $(date -u +%Y-%m-%d)" git push - name: Sync to HF Spaces env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | git remote add hf "https://fmegahed:${HF_TOKEN}@huggingface.co/spaces/fmegahed/timeseries_visualization" || \ git remote set-url hf "https://fmegahed:${HF_TOKEN}@huggingface.co/spaces/fmegahed/timeseries_visualization" git push hf HEAD:main --force