A GitHub Action that automatically labels and types GitHub issues using OpenAI's language models with structured outputs.
- 🤖 AI-Powered Classification: Uses OpenAI's language models to analyze issue content
- 🏷️ Smart Labeling: Applies multiple relevant labels based on issue title and description
- 📝 Type Classification: Categorizes issues as Bug, Feature, or Task
- 🔧 Customizable: Add custom labels with descriptions for your specific project needs
- 📊 Structured Outputs: Uses OpenAI's structured output feature for reliable JSON responses
- 🛡️ Error Handling: Graceful error handling with detailed logging
- 🎯 Label Management: Automatically creates missing labels in your repository
The action includes these default labels:
bug- Something isn't workingenhancement- New feature or requestdocumentation- Improvements or additions to documentationhelp wanted- Extra attention is neededquestion- Further information is requested
Issues are classified into one of these types:
Bug- Issues reporting problems, errors, or unexpected behaviorFeature- Requests for new functionality or enhancementsTask- General tasks, maintenance, or process-related issues
name: Auto-label Issues
on:
issues:
types: [opened, edited]
jobs:
label-issue:
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
steps:
- name: Label Issue with LLM
uses: your-username/llm-labeler@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}- name: Label Issue with LLM
uses: your-username/llm-labeler@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
openai-endpoint: "https://api.openai.com/v1"
openai-model: "gpt-4o-mini"
custom-labels: |
[
{
"label": "security",
"description": "Security-related issues or vulnerabilities"
},
{
"label": "performance",
"description": "Performance optimization or issues"
},
{
"label": "ui/ux",
"description": "User interface or user experience related"
},
{
"label": "api",
"description": "API-related changes or issues"
}
]| Input | Description | Required | Default |
|---|---|---|---|
github-token |
GitHub token for API access | Yes | - |
openai-api-key |
OpenAI API key | Yes | - |
openai-endpoint |
OpenAI API endpoint | No | https://api.openai.com/v1 |
openai-model |
OpenAI model to use | No | gpt-4o-mini |
custom-labels |
JSON array of custom labels with descriptions | No | [] |
| Output | Description |
|---|---|
labels-applied |
Comma-separated list of labels applied to the issue |
type-applied |
Type classification applied to the issue |
Custom labels should be provided as a JSON array with label and description fields:
[
{
"label": "security",
"description": "Security-related issues or vulnerabilities"
},
{
"label": "performance",
"description": "Performance optimization or issues"
}
]The GitHub token needs the following permissions:
issues: write- To apply labels to issuescontents: read- To read repository content
- Add OpenAI API Key: Add your OpenAI API key as a repository secret named
OPENAI_API_KEY - Create Workflow: Add the workflow file to
.github/workflows/in your repository - Configure Permissions: Ensure the workflow has the required permissions
- Trigger: Action runs when issues are opened or edited
- Analysis: Sends issue title and description to OpenAI for analysis
- Classification: AI returns structured output with labels and type
- Validation: Filters suggested labels to only include available ones
- Application: Applies labels and type to the GitHub issue
- Label Creation: Creates any missing labels in the repository
Input Issue:
- Title: "App crashes when clicking the login button"
- Description: "The mobile app crashes consistently when users try to log in..."
AI Analysis Result:
- Labels:
bug,help wanted - Type:
Bug - Reasoning: "This is clearly a bug report describing a crash issue that needs immediate attention"
Input Issue:
- Title: "Add OAuth authentication support"
- Description: "We need to implement OAuth2 authentication for better security..."
AI Analysis Result:
- Labels:
enhancement,security,api - Type:
Feature - Reasoning: "This is a feature request for authentication enhancement with security implications"
To build and test the action locally:
# Install dependencies
pnpm install
# Build the action
pnpm run build
# Package for distribution
pnpm run package- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details
- Create an issue for bug reports or feature requests
- Check existing issues for common problems
- Review the action logs for debugging information