Overview
GitHub Actions automates your daily story generation. The workflow runs on a schedule, generates a new story using AI, and commits the results back to your repository.Workflow File Breakdown
The complete workflow is defined in.github/workflows/actualizar.yml:
.github/workflows/actualizar.yml
Workflow Components
Workflow Name
Workflow Name
Triggers
Triggers
- Schedule (cron): Runs automatically at specified time
- workflow_dispatch: Allows manual triggering via GitHub UI button
Job Configuration
Job Configuration
- runs-on: Specifies Ubuntu Linux virtual machine
- permissions: Grants write access to commit files back to repository
Steps
Steps
The workflow executes 5 sequential steps:
- Checkout code: Downloads repository to VM
- Setup Python: Installs Python 3.10
- Install dependencies: Installs
requestslibrary - Run script: Executes
generar_historia.pywith API key - Commit & push: Saves generated files back to repository
Schedule Configuration (Cron Syntax)
Understanding Cron
The cron expression defines when the workflow runs:minute hour day month weekday
| Position | Current Value | Meaning |
|---|---|---|
| Minute | 0 | At minute 0 |
| Hour | 13 | At 1:00 PM (UTC) |
| Day | * | Every day |
| Month | * | Every month |
| Weekday | * | Every day of week |
Common Schedule Examples
Timezone Conversion Table
| Your Local Time | Timezone | UTC Equivalent | Cron Expression |
|---|---|---|---|
| 8:00 AM | EST (UTC-5) | 13:00 | 0 13 * * * |
| 9:00 AM | PST (UTC-8) | 17:00 | 0 17 * * * |
| 12:00 PM | GMT (UTC+0) | 12:00 | 0 12 * * * |
| 3:00 PM | CET (UTC+1) | 14:00 | 0 14 * * * |
| 10:00 AM | IST (UTC+5:30) | 04:30 | 30 4 * * * |
Manual Triggers
Theworkflow_dispatch trigger enables manual workflow execution:
.github/workflows/actualizar.yml
How to Manually Run
Manual triggers are perfect for testing changes without waiting for the scheduled time.
Permissions Setup
The workflow requires write permissions to commit generated files:.github/workflows/actualizar.yml
Verifying Permissions
Viewing Workflow Logs
Logs help you understand what happened during each run.Accessing Logs
Understanding Log Output
Each step shows its output:Example Success Log
Troubleshooting Failed Runs
Common Errors
Error: API Key Not Found
Error: API Key Not Found
Symptom:Cause: Missing or incorrect
OPENROUTER_API_KEY secretSolution:- Go to Settings → Secrets and variables → Actions
- Verify
OPENROUTER_API_KEYexists - If missing, add it with your OpenRouter API key
- Re-run the workflow
Error: Permission Denied (403)
Error: Permission Denied (403)
Symptom:Cause: Workflow lacks write permissionsSolution:
- Go to Settings → Actions → General
- Under Workflow permissions, select Read and write permissions
- Save and re-run the workflow
Error: Module Not Found
Error: Module Not Found
Symptom:Cause: Dependencies not installed properlySolution:
Ensure step 3 in your workflow includes:
Error: Nothing to Commit
Error: Nothing to Commit
Symptom:Cause: Script didn’t generate or modify any filesSolution:
This can be normal if the script had an error. Check step 4 logs:Look for Python errors or API failures.
Error: Rate Limit Exceeded
Error: Rate Limit Exceeded
Symptom:Cause: OpenRouter rate limit reached (common with free models)Solution:
- Wait 1-2 hours and try again
- Switch to a paid model
- Reduce workflow frequency
Error: Workflow Didn't Run
Error: Workflow Didn't Run
Symptom: Scheduled workflow didn’t execute at expected timeCause: GitHub Actions can be delayed by up to 15 minutes during high loadSolution:
- Wait 15-30 minutes past scheduled time
- Check Actions tab for any queued runs
- Manually trigger to test if workflow works
Debugging Steps
Test Locally
Run
python generar_historia.py on your local machine with the API key set as an environment variable:Advanced Workflow Customization
Adding Notifications
Send yourself an email when workflow fails:Add Email Notification
Run Only on Specific Branches
Branch-Specific Trigger
Add Timeout Protection
Prevent Long Runs
Multiple Python Dependencies
If you add more Python libraries:requirements.txt Approach
requirements.txt in your repository:
requirements.txt
Workflow Best Practices
Test First
Always use manual triggers to test changes before relying on scheduled runs
Monitor Costs
Check OpenRouter usage regularly if using paid models
Keep Secrets Safe
Never commit API keys directly in code. Always use GitHub Secrets
Review Logs
Check workflow logs weekly to catch any silent failures
Next Steps
API Setup
Configure OpenRouter API and select models
Customization
Customize prompts, templates, and styling