A powerful, AI-enhanced GitHub automation suite built with Motia framework
Features β’ Quick Start β’ API Endpoints β’ Examples β’ Contributing
- π Repository Stats Dashboard - Comprehensive repo analytics with stars, forks, languages, and top contributors
- π¦ Release Notes Viewer - Fetch latest or all releases with download stats
- π Code Activity Tracker - Analyze commit patterns, active hours, and contributor stats
- π» Personal Commits Viewer - List all your commits in any repository
- π€ AI-Powered PR Review - Automated code review using Google Gemini AI
- π·οΈ Smart Auto-Labeler - Automatically label PRs based on file changes
- Node.js 18+ installed
- GitHub Personal Access Token (Create one here)
- Google Gemini API Key (Get it here)
# Clone the repository
git clone https://github.com/Pratham-Prog861/github-pr-automation.git
cd github-pr-automation
# Install dependencies
npm install
# Create .env file
cat > .env << EOF
GITHUB_TOKEN=your_github_token_here
GEMINI_API_KEY=your_gemini_api_key_here
EOF
# Generate TypeScript types
npm run generate-types
# Start the development server
npm run devπ Server is now running at http://localhost:3000
GET /repo-stats?repo=owner/repoExample Response:
{
"ok": true,
"stats": {
"name": "mini-postman",
"stars": 42,
"forks": 15,
"languages": [
{ "language": "TypeScript", "percentage": "85.50" }
],
"topContributors": [...]
}
}GET /releases?repo=owner/repo&latest=trueQuery Parameters:
repo(required) - Repository in formatowner/repolatest(optional) -truefor latest release,falsefor all releases (default:true)
GET /repo-activity?repo=owner/repo&days=30Query Parameters:
repo(required) - Repository in formatowner/repodays(optional) - Number of days to analyze (default:30)
GET /repo-commits?repo=owner/repoReturns the last 10 commits authored by you in the specified repository.
POST /review-pr
Content-Type: application/json
{
"repo": "owner/repo",
"prNumber": 123
}What it does:
- β Fetches PR files and diff
- π Runs AI-powered code review using Gemini
- π Posts detailed review comment on GitHub
- β¨ Auto-approves if lint passes and AI approves
POST /auto-label
Content-Type: application/json
{
"repo": "owner/repo",
"prNumber": 123
}Labeling Rules:
| File Pattern | Label |
|---|---|
.ts, .tsx |
typescript |
.js, .jsx |
javascript |
.css, .scss |
styling |
.md |
documentation |
test, spec |
tests |
package.json |
dependencies |
# Get repository statistics
curl "http://localhost:3000/repo-stats?repo=facebook/react"
# Get latest release
curl "http://localhost:3000/releases?repo=vercel/next.js&latest=true"
# Analyze last 7 days of activity
curl "http://localhost:3000/repo-activity?repo=microsoft/vscode&days=7"
# Review a pull request
curl -X POST http://localhost:3000/review-pr \
-H "Content-Type: application/json" \
-d '{"repo":"owner/repo","prNumber":42}'
# Auto-label a PR
curl -X POST http://localhost:3000/auto-label \
-H "Content-Type: application/json" \
-d '{"repo":"owner/repo","prNumber":42}'// Fetch repository stats
const stats = await fetch(
"http://localhost:3000/repo-stats?repo=facebook/react"
).then((res) => res.json());
console.log(`β Stars: ${stats.stats.stars}`);
console.log(`π΄ Forks: ${stats.stats.forks}`);
// Auto-label a PR
const result = await fetch("http://localhost:3000/auto-label", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
repo: "owner/repo",
prNumber: 42,
}),
}).then((res) => res.json());
console.log(`π·οΈ Labels added: ${result.labelsAdded.join(", ")}`);github-pr-automation/
βββ steps/ # API endpoint definitions
β βββ github-pr-review.step.ts # AI-powered PR review
β βββ github-auto-labeler.step.ts # Smart PR labeler
β βββ github-commits.step.ts # Personal commits viewer
β βββ github-repo-stats.step.ts # Repository statistics
β βββ github-releases.step.ts # Release notes viewer
β βββ github-activity.step.ts # Code activity tracker
βββ motia.config.ts # Motia configuration
βββ types.d.ts # Auto-generated TypeScript types
βββ .env # Environment variables (create this)
βββ package.json # Dependencies
# Start development server with hot reload
npm run dev
# Generate TypeScript types from Step configs
npm run generate-types
# Build for production
npm run build
# Clean build artifacts
npm run clean- Create a new file in
steps/directory (e.g.,my-feature.step.ts) - Define your step configuration and handler
- Run
npm run generate-typesto register it - Test your endpoint at
http://localhost:3000/your-path
Example:
import { ApiRouteConfig, Handlers } from "motia";
export const config: ApiRouteConfig = {
name: "my-feature",
type: "api",
path: "/my-endpoint",
method: "GET",
emits: [],
};
export const handler: Handlers["my-feature"] = async (req, ctx) => {
return {
status: 200,
body: { message: "Hello from my feature!" },
};
};Create a .env file in the root directory:
# GitHub Personal Access Token (required)
# Scopes needed: repo, read:user
GITHUB_TOKEN=ghp_your_token_here
# Google Gemini API Key (required for PR review)
GEMINI_API_KEY=AIzaSy_your_key_hereGitHub Token:
- Go to GitHub Settings β Developer settings β Personal access tokens
- Click "Generate new token (classic)"
- Select
reposcope - Copy the generated token
Gemini API Key:
- Visit Google AI Studio
- Click "Get API key"
- Create a new API key
- Copy the key
Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment into one unified system using a single core primitive, the Step.
| Type | When it runs | Use case |
|---|---|---|
api |
HTTP request | REST APIs, webhooks |
event |
Event emitted | Background jobs, workflows |
cron |
Schedule | Cleanup, reports, reminders |
Contributions are welcome! Here's how you can help:
- π΄ Fork the repository
- πΏ Create a feature branch (
git checkout -b feature/amazing-feature) - π» Make your changes
- β Test your changes
- π Commit your changes (
git commit -m 'Add amazing feature') - π Push to the branch (
git push origin feature/amazing-feature) - π Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- π Motia Documentation
- π¬ Discord Community
- π Report Issues
- β Star this repo
Made with β€οΈ using Motia
If you found this helpful, please β star the repository!