name: Daily Health Check

on:
  schedule:
    - cron: '0 12 * * *'
    - cron: '0 0 * * *'
  workflow_dispatch:

jobs:
  health:
    runs-on: ubuntu-latest
    timeout-minutes: 15

    steps:
      - uses: actions/checkout@v4

      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'
          cache: 'pip'

      - name: Install dependencies
        run: |
          pip install -e ".[dev]"

      - name: Run health checks
        id: health
        run: |
          python scripts/fetch_structures.py --output health_report.json
          echo "report_path=health_report.json" >> $GITHUB_OUTPUT

      - name: Upload report
        uses: actions/upload-artifact@v4
        with:
          name: health-report-${{ github.run_number }}
          path: health_report.json
          retention-days: 30
