Skip to content

Sync Upcoming TV Episodes #56

Sync Upcoming TV Episodes

Sync Upcoming TV Episodes #56

name: Sync Upcoming TV Episodes
on:
schedule:
# Run daily at 8:00 AM Bangladesh Time (2:00 AM UTC)
# Bangladesh Time = UTC+6, so 8:00 AM BST = 2:00 AM UTC
- cron: '0 2 * * *'
workflow_dispatch: # Allow manual trigger from GitHub UI
push:
branches:
- main
paths:
- 'scripts/sync_upcoming_episodes.py'
- 'models.py'
- 'api/tmdb_client.py'
permissions:
contents: read
issues: write # Permission to create issues on failure
jobs:
sync-episodes:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run sync script
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
TMDB_API_KEY: ${{ secrets.TMDB_API_KEY }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
# AI/Vector DB credentials (optional for sync script)
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
CHROMA_API_KEY: ${{ secrets.CHROMA_API_KEY }}
CHROMA_TENANT: ${{ secrets.CHROMA_TENANT }}
CHROMA_DATABASE: ${{ secrets.CHROMA_DATABASE }}
run: |
python scripts/sync_upcoming_episodes.py
continue-on-error: false
- name: Notify on failure
if: failure()
uses: actions/github-script@v7
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🚨 TV Episode Sync Failed',
body: `The scheduled sync of upcoming TV episodes failed.\n\n**Workflow Run**: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}\n\n**Date**: ${new Date().toISOString()}\n\nPlease check the logs and ensure the TMDb API and database are accessible.`,
labels: ['automation', 'bug']
})