carvalhocaio/routines-in-the-night
A TypeScript application that automatically generates daily summaries of your GitHub activity using Google's Gemini AI and sends them to Discord. Perfect for developers who want to track and share their coding progress.
GitHub Daily Reporter (Bun + Gemini)
A TypeScript application that automatically generates daily summaries of your GitHub activity using Google's Gemini AI and sends them to Discord. Perfect for developers who want to track and share their coding progress.
Features
- Comprehensive Activity Tracking: Monitors both public and private repository events
- AI-Powered Summaries: Uses Google Gemini to generate concise, engaging summaries
- Discord Integration: Automatically posts daily reports to Discord channels via webhooks
- GitHub Actions Automation: Runs daily at midnight (Brasília time) using GitHub Actions
- Robust Error Handling: Request timeouts, retry logic with exponential backoff
- Event Filtering: Captures activities from the last 24 hours including:
- Push events with commit details
- Repository creation and deletion
- Issue management
- Pull request activities
- Branch operations
Prerequisites
- Bun v1.0 or higher
- GitHub Personal Access Token
- Google Gemini API Key
- Discord Webhook URL
Installation
Local Setup
- Clone the repository:
git clone https://github.com/carvalhocaio/routines-in-the-night
cd routines-in-the-night- Install dependencies:
bun install- Configure environment variables:
cp .env.sample .envEdit .env with your credentials:
GH_USER=your_github_username
GH_TOKEN=your_github_personal_access_token
GEMINI_API_KEY=your_gemini_api_key
GEMINI_MODEL=gemini-2.5-flash # Optional, defaults to gemini-2.5-flash
DISCORD_WEBHOOK_URL=your_discord_webhook_urlConfiguration
GitHub Personal Access Token
Create a GitHub Personal Access Token with the following scopes:
repo(for private repository access)user(for user events access)
Gemini API Key
- Go to Google AI Studio
- Create a new API key
- Copy the key to your
.envfile
Discord Webhook
- Go to your Discord server settings
- Navigate to Integrations > Webhooks
- Create a new webhook and copy the URL
Usage
Local Execution
bun run startOr with watch mode for development:
bun run devAutomated Execution
The project includes a GitHub Actions workflow that runs automatically every day at midnight (Brasília time).
To enable automation:
-
Add the required secrets to your GitHub repository:
GH_USERGH_TOKENGEMINI_API_KEYDISCORD_WEBHOOK_URL
-
The workflow will run automatically or can be triggered manually from the Actions tab.
Project Structure
.
├── src/
│ ├── index.ts # Application entry point
│ ├── config/
│ │ └── index.ts # Configuration management
│ ├── github/
│ │ ├── client.ts # GitHub API client
│ │ └── types.ts # GitHub event types
│ ├── gemini/
│ │ ├── client.ts # Gemini AI client
│ │ └── prompt.ts # AI prompt template
│ ├── discord/
│ │ ├── client.ts # Discord webhook client
│ │ └── types.ts # Discord embed types
│ └── utils/
│ └── fetch.ts # Fetch with retry and timeout
├── .github/
│ └── workflows/
│ ├── ci.yml # CI workflow (test, lint, typecheck)
│ └── daily-github-report.yml # Daily report workflow
├── .env.sample # Environment variables template
├── biome.json # Linter/formatter configuration
├── package.json # Project dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # This file
Development
Available Commands
bun run start # Run the application
bun run dev # Run with watch mode
bun test # Run tests
bun run lint # Run Biome linter
bun run format # Format code with Biome
bun run check # Run all Biome checks
bun run tsc # Type checkRunning Tests
bun testLinting & Formatting
bun run lint # Check for issues
bun run format # Fix formattingArchitecture
The application follows clean architecture principles with clear separation of concerns:
- src/config: Configuration loading and validation
- src/github: GitHub API integration with retry logic
- src/gemini: Gemini AI integration for summary generation
- src/discord: Discord webhook integration
- src/utils: Shared utilities (fetch with retry/timeout)
Each module is independent and testable.
How It Works
- Event Retrieval: The GitHub client fetches events from the last 24 hours using the GitHub API
- Event Processing: Events are filtered and formatted to extract relevant information
- AI Summary Generation: Gemini AI processes the events and generates a detailed technical summary in Portuguese
- Discord Notification: The summary is sent to Discord as an embedded message with timestamp
If no events are found, a "no activity" message is sent to Discord instead.
Event Types Tracked
- PushEvent: Code pushes with commit messages
- CreateEvent: Repository, branch, or tag creation
- DeleteEvent: Repository, branch, or tag deletion
- IssuesEvent: Issue creation, closing, or updates
- PullRequestEvent: PR creation, merging, or updates
Error Handling
The application includes comprehensive error handling:
- Request timeouts (30s for GitHub/Gemini, 15s for Discord)
- Retry logic with exponential backoff for transient errors (429, 5xx)
- Detailed error messages with context
- Error notifications sent to Discord for monitoring
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Format your code (
bun run format) - Run tests (
bun test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is open source and available under the MIT License.
Acknowledgments
- Google Gemini AI for AI-powered summaries
- GitHub API for event tracking
- Discord Webhooks for notifications
- Bun for the fast JavaScript runtime
Support
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with details about your problem
- Include logs and environment information