What is Historia Diaria?
Historia Diaria is an automated daily story generator that uses AI to create short science fiction and fantasy stories every day. It’s a demonstration project that combines the power of OpenRouter AI with GitHub Actions automation to generate, store, and display daily creative content on a beautiful web interface.Historia Diaria generates a new story automatically every day at 8:00 AM (Lima time) and publishes it to GitHub Pages - completely hands-free!
What Problem Does It Solve?
Historia Diaria showcases how to:- Automate creative content generation using AI APIs in a scheduled workflow
- Build a dynamic archive of generated content organized by month and year
- Deploy static sites automatically with GitHub Actions and GitHub Pages
- Integrate external APIs (OpenRouter, Picsum Photos) into automated workflows
- Learn GitHub Actions through a practical, fun project
Key Features
🤖 AI-Powered Story Generation
Uses OpenRouter’s API with thestepfun/step-3.5-flash:free model to generate unique stories daily. The AI follows a structured prompt to return stories with a title, narrative, and image keyword.
⏰ Fully Automated Workflow
GitHub Actions runs the story generation script daily at 8:00 AM Lima time (13:00 UTC). You can also trigger it manually with a button click for testing.📚 Persistent History System
Stories are organized chronologically in a JSON-based history system (historial.json) that tracks all generated stories by month and year.
🎨 Beautiful Web Interface
A responsive HTML template with:- Sidebar navigation for browsing past stories
- Random images from Picsum Photos
- Clean, modern design optimized for readability
- Mobile-friendly layout
🔄 Smart Update Logic
The system intelligently handles:- Creating new entries for each day
- Updating existing entries if run multiple times per day
- Building dynamic navigation menus from the history
- Generating both
index.htmland dated archive files
Architecture Overview
Historia Diaria consists of three main components:1. Story Generation Script (generar_historia.py)
1. Story Generation Script (generar_historia.py)
The core Python script that:
- Connects to OpenRouter API with your API key
- Sends a structured prompt requesting a story
- Parses the AI response using regex to extract title and content
- Generates a unique image URL using Picsum Photos
- Updates the history JSON file
- Renders the HTML template with new content
2. GitHub Actions Workflow (actualizar.yml)
2. GitHub Actions Workflow (actualizar.yml)
The automation engine that:
- Runs on a daily schedule (13:00 UTC)
- Sets up a Python environment on Ubuntu
- Installs dependencies (requests)
- Executes the generation script with API key from secrets
- Commits and pushes changes back to the repository
3. HTML Template System (plantilla.html)
3. HTML Template System (plantilla.html)
A responsive web template featuring:
- Variable placeholders for dynamic content (
{{TITULO}},{{HISTORIA}},{{IMAGEN_URL}},{{MENU}}) - Sidebar navigation with toggle functionality
- Modern styling with CSS
- JavaScript for interactive menu
Data Flow Diagram
History File Structure
Thehistorial.json file organizes stories by month:
Technical Requirements
- Python: 3.10 or higher
- Dependencies:
requestslibrary - API Key: OpenRouter API key (free tier available)
- Hosting: GitHub Pages (free)
- Repository: GitHub repository with Actions enabled
Use Cases
Learning GitHub Actions
Understand how to set up scheduled workflows, secrets, and automated deployments
Content Generation
Create automated content pipelines for blogs, newsletters, or creative projects
API Integration
Learn how to integrate external APIs into automated workflows
Template Systems
Build dynamic web pages from templates and structured data
Ready to Get Started?
Quickstart Guide
Follow our step-by-step guide to set up your own Historia Diaria instance in under 10 minutes
Historia Diaria is designed to be beginner-friendly. If you can fork a repository and add a secret, you can run this project!