Get Started in Minutes
This guide will walk you through setting up your own Historia Diaria instance - an automated daily story generator powered by AI and GitHub Actions.Time to complete: ~10 minutes
Prerequisites: A GitHub account (free) and an OpenRouter API key (free tier available)
Prerequisites: A GitHub account (free) and an OpenRouter API key (free tier available)
Setup Overview
Fork the Repository
- Go to the Historia Diaria repository
- Click the Fork button in the top-right corner
- Wait for GitHub to create your own copy of the repository
Forking creates an independent copy of the project under your account. You’ll have full control to customize and run it.
Get Your OpenRouter API Key
Historia Diaria uses OpenRouter to access AI models. Here’s how to get your free API key:
- Visit OpenRouter.ai
- Sign up for a free account
- Navigate to your API Keys section
- Click Create Key and copy your API key
stepfun/step-3.5-flash:free model which is available on the free tier.Configure GitHub Secrets
Store your API key securely in GitHub Secrets:
- In your forked repository, click Settings (top menu)
- In the left sidebar, expand Secrets and variables → click Actions
- Click New repository secret
- Enter the following:
- Name:
OPENROUTER_API_KEY - Secret: Paste your API key from step 2
- Name:
- Click Add secret
GitHub Secrets are encrypted and only exposed to workflows. They’re never visible in logs or to other users.
Enable GitHub Actions
GitHub Actions may be disabled by default on forked repositories:
- Go to the Actions tab in your repository
- If you see a message about workflows being disabled, click I understand my workflows, go ahead and enable them
- You should now see the “Actualizar Historia Diaria” workflow
This step is crucial - without enabling Actions, the automated workflow won’t run!
Enable GitHub Pages
Configure GitHub Pages to publish your stories:
- Go to Settings → Pages (in the left sidebar)
- Under Source, select Deploy from a branch
- Under Branch, select main (or master) and / (root)
- Click Save
https://YOUR_USERNAME.github.io/historia-diaria/It may take a few minutes for your site to become available after the first deployment.
Test the Workflow
Trigger your first story generation manually:If the workflow succeeds, you’ll see:
- Go to the Actions tab
- Click on Actualizar Historia Diaria workflow (left sidebar)
- Click the Run workflow button (right side)
- Click the green Run workflow button in the dropdown
- Wait ~30-60 seconds for the workflow to complete
- A green checkmark ✓
- New files committed to your repository:
index.html,historia-YYYY-MM-DD.html, updatedhistorial.json
View Your Generated Story
Once the workflow completes and GitHub Pages deploys:
- Visit
https://YOUR_USERNAME.github.io/historia-diaria/ - You should see your first AI-generated story!
- Click the ☰ menu icon to see the sidebar navigation
- Past stories will appear in the history organized by month
GitHub Pages deployment can take 2-5 minutes after the workflow completes. Be patient on your first run!
Customize Your Instance
Now that your instance is running, here are some ways to customize it:Change the Story Prompt
Change the Story Prompt
Edit the prompt in Ideas to try:
generar_historia.py to generate different types of stories:generar_historia.py
- Change the genre: “mystery”, “horror”, “romance”, “humor”
- Add style requirements: “in the style of Edgar Allan Poe”
- Set themes: “stories about time travel”, “underwater adventures”
- Adjust length: “one paragraph” or “five paragraphs”
Adjust the Schedule
Adjust the Schedule
Modify when stories are generated by editing the cron schedule in Cron syntax:
.github/workflows/actualizar.yml:actualizar.yml
minute hour day month weekdayExamples:'0 0 * * *'- Midnight UTC every day'0 12 * * *'- Noon UTC every day'0 9 * * 1'- 9:00 AM UTC every Monday'0 */6 * * *'- Every 6 hours
GitHub Actions uses UTC timezone. Convert your local time to UTC when setting the schedule.
Change the AI Model
Change the AI Model
Switch to a different AI model by editing the model parameter in Free models on OpenRouter:
generar_historia.py:generar_historia.py
google/gemini-2.0-flash-exp:free- Google’s Gemini Flashmeta-llama/llama-3.1-8b-instruct:free- Llama 3.1microsoft/phi-3-mini-128k-instruct:free- Microsoft Phi-3
Customize the HTML Template
Customize the HTML Template
Edit Template variables:
plantilla.html to change the look and feel of your stories:plantilla.html
{{TITULO}}- Story title{{HISTORIA}}- Story content{{IMAGEN_URL}}- Random image URL{{MENU}}- Sidebar navigation HTML
Keep the
{{VARIABLE}} placeholders intact - the script replaces these with actual content.Modify Image Generation
Modify Image Generation
The script uses Picsum Photos for random images. Edit Alternatives:Or integrate with other image services like Unsplash API.
generar_historia.py to customize:generar_historia.py
Understanding the Generated Files
After each run, the workflow creates/updates these files:Troubleshooting
Workflow fails with 'Permission denied' error
Workflow fails with 'Permission denied' error
Cause: GitHub Actions doesn’t have write permissions.Solution:
- Go to Settings → Actions → General
- Scroll to Workflow permissions
- Select Read and write permissions
- Click Save
Story shows 'Error al conectar con la API'
Story shows 'Error al conectar con la API'
Cause: API key is missing or invalid.Solution:
- Verify your OpenRouter API key is valid
- Check the secret name is exactly
OPENROUTER_API_KEY - Re-add the secret in Settings → Secrets and variables → Actions
- Run the workflow again
GitHub Pages shows 404 error
GitHub Pages shows 404 error
Cause: Pages not enabled or files not in correct location.Solution:
- Verify GitHub Pages is enabled (Settings → Pages)
- Confirm source is set to main branch and / (root)
- Wait 2-5 minutes after the first deployment
- Check that
index.htmlexists in your repository root - Try accessing
https://YOUR_USERNAME.github.io/historia-diaria/index.htmldirectly
Schedule not working (no automatic runs)
Schedule not working (no automatic runs)
Cause: GitHub disables scheduled workflows on inactive forks.Solution:
- Ensure you’ve made at least one commit to your fork
- GitHub may disable schedules after 60 days of repository inactivity
- Manual workflow runs keep the repository “active”
- You can trigger manually anytime using
workflow_dispatch
Same story appears multiple times
Same story appears multiple times
Cause: Multiple workflow runs on the same day.Solution: This is expected behavior! The script updates the entry for today if it already exists:The system prevents duplicate entries by checking if a file for today already exists.
generar_historia.py
Next Steps
Customize Your Project
Learn how to customize prompts, templates, and styling
Understanding the Code
Deep dive into the script structure and components
GitHub Actions Workflow
Optimize your GitHub Actions workflow configuration
API Setup Guide
Explore OpenRouter API configuration and model options
Need Help?
If you run into issues not covered in this guide, check the workflow logs in the Actions tab. They provide detailed error messages and execution traces.