Why Automate GitHub PR Labeling?
Managing pull requests can quickly get messy — especially when labels are inconsistent. Labels help your team prioritize work, track bugs, and organize releases. But manually adding them wastes time and often leads to errors.
This n8n workflow automates GitHub PR labeling using AI. It looks at PR titles, descriptions, commits, and diffs, then applies the most relevant label automatically. The result: faster code reviews and smoother project management.
How the Automation Works
- GitHub Trigger: The workflow starts when a new pull request is opened.
- Commit Data: It fetches all related commit details for context.
- Repository Labels: An API call retrieves the full list of labels in your repo.
- Code Node Cleanup: A small script extracts clean label names for the AI to choose from.
- AI Labeling: Using Groq’s LLaMA 3.3-70B via LangChain, the workflow analyzes PR metadata, commits, and diffs to predict the best matching label.
- Validation: A structured parser ensures the AI returns a valid label from your repo’s list.
- Apply Label: An HTTP Request node applies the predicted label directly to the pull request.
Pro Tips and Variations
- Define custom rules to override AI predictions for critical labels like security or release-blocker.
- Use Slack integration to notify reviewers when a PR is auto-labeled.
- Expand this workflow to auto-assign reviewers based on label categories.
Build Smarter DevOps Automations
Want to automate more of your development workflow with AI? Let our team help you design and deploy custom n8n workflows.