FPL Data Ingestion #129
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: FPL Data Ingestion | |
| on: | |
| schedule: | |
| # Run at 5:15 AM UTC (15 minutes after FPL-Elo-Insights updates at 5 AM) | |
| - cron: '15 5 * * *' | |
| # Run at 5:15 PM UTC (17:15 UTC, 15 minutes after FPL-Elo-Insights updates at 5 PM) | |
| - cron: '15 17 * * *' | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| ingest-data: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| issues: write | |
| steps: | |
| - name: Checkout main repository | |
| uses: actions/checkout@v4 | |
| - name: Checkout FPL-Elo-Insights repository | |
| run: | | |
| git clone --depth 1 https://github.com/olbauday/FPL-Elo-Insights.git temp-elo-data | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| cache-dependency-path: flask-api/requirements.txt | |
| - name: Install dependencies | |
| working-directory: flask-api | |
| run: | | |
| pip install -r requirements.txt | |
| - name: Verify database secrets | |
| run: | | |
| if [ -z "${{ secrets.DB_HOST }}" ]; then | |
| echo "❌ Error: DB_HOST secret is not set" | |
| exit 1 | |
| fi | |
| if [ -z "${{ secrets.DB_PASSWORD }}" ]; then | |
| echo "❌ Error: DB_PASSWORD secret is not set" | |
| exit 1 | |
| fi | |
| echo "✅ Database secrets are configured" | |
| echo "DB_HOST: ${{ secrets.DB_HOST }}" | |
| echo "DB_USER: ${{ secrets.DB_USER || 'postgres' }}" | |
| echo "DB_NAME: ${{ secrets.DB_NAME || 'postgres' }}" | |
| echo "DB_PORT: ${{ secrets.DB_PORT || '5432' }}" | |
| - name: Run data ingestion | |
| working-directory: flask-api | |
| env: | |
| DB_HOST: ${{ secrets.DB_HOST }} | |
| DB_USER: ${{ secrets.DB_USER || 'postgres' }} | |
| DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| DB_NAME: ${{ secrets.DB_NAME || 'postgres' }} | |
| DB_PORT: ${{ secrets.DB_PORT || '5432' }} | |
| ELO_DATA_PATH: ../temp-elo-data/data | |
| run: | | |
| python scripts/ingest_elo_and_fpl.py | |
| - name: Notify on failure | |
| if: failure() | |
| uses: actions/github-script@v7 | |
| continue-on-error: true | |
| with: | |
| script: | | |
| try { | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: 'Data Ingestion Failed', | |
| body: 'The scheduled FPL data ingestion failed. Please check the workflow logs.' | |
| }); | |
| } catch (error) { | |
| console.log('Failed to create issue notification:', error.message); | |
| // Don't fail the workflow if notification fails | |
| } | |