This example demonstrates building an intelligent GitHub PR management system with:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/motiadev/motia/llms.txt
Use this file to discover all available pages before exploring further.
- Webhook-based PR event handling
- Automated code review with AI
- CI/CD integration
- Automated merge policies
- Status notifications
View source code
Complete source code on GitHub
Use cases
- Automated PR reviews
- Code quality checks
- Auto-merge for approved PRs
- PR status notifications
- Developer productivity tracking
Architecture
The workflow consists of:- Webhook receiver: Handles GitHub webhook events
- PR analyzer: Analyzes code changes with AI
- Test runner: Triggers and monitors CI tests
- Review poster: Posts review comments
- Merge coordinator: Handles auto-merge logic
Prerequisites
Set up GitHub integration:- Create a GitHub App or personal access token
- Configure webhook URL:
https://your-app.com/webhooks/github - Subscribe to PR events:
pull_request,pull_request_review,check_run - Set webhook secret for security
Step 1: Receive GitHub webhooks
Createsteps/github-webhook.step.ts to handle webhook events:
steps/github-webhook.step.ts
Step 2: Analyze PR with AI
Createsteps/analyze-pr.step.ts for AI code review:
steps/analyze-pr.step.ts
Step 3: Post review comments
Createsteps/post-review.step.ts to post comments:
steps/post-review.step.ts
Step 4: Auto-merge logic
Createsteps/auto-merge.step.ts for automated merging:
steps/auto-merge.step.ts
Configuration
Set environment variables:.env
Testing
- Open a PR in your GitHub repository
- Watch the iii Console for webhook processing
- See AI review comments appear on the PR
- Approve the PR to trigger auto-merge
What you learned
Webhooks
Handle GitHub webhook events
AI code review
Use LLMs to analyze code changes
Conditional workflows
Build complex automation logic
External APIs
Integrate with GitHub API
Next steps
More examples
Explore 20+ examples on GitHub
Deployment guide
Deploy your workflows to production