Automatically labels GitHub discussions using AI to analyze content and apply appropriate tags.
- Automatically applies labels to new GitHub discussions
- Uses Azure OpenAI for content analysis
- Supports both GitHub token and GitHub App authentication
- Can be run locally or as a GitHub Action
- Includes a utility to create repository labels
- Python 3.10+
- GitHub token or GitHub App credentials
- Azure OpenAI service (for AI-based labeling)
- Clone this repository
- Install dependencies:
pip install -r requirements.txt
- Copy
.env.sample
to.env
and fill in your credentials
Variable | Description |
---|---|
TOKEN |
GitHub personal access token |
APP_ID |
GitHub App ID |
APP_PRIVATE_KEY |
GitHub App private key (content as string) |
APP_INSTALLATION_ID |
GitHub App installation ID |
DEFAULT_REPO |
Repository to monitor in format owner/repo |
AZURE_OPENAI_ENDPOINT |
Azure OpenAI API endpoint |
AZURE_OPENAI_KEY |
Azure OpenAI API key |
AZURE_OPENAI_API_VERSION |
Azure OpenAI API version |
RUN_INTERVAL_MINUTES |
How often to check for new discussions (in minutes) |
To run the script locally and continuously monitor for new discussions:
python basic.py
To create the labels defined in tags.json
in your repository:
python new-labels.py
This repo includes a GitHub Action workflow that automatically runs when new discussions are created.
To set up the GitHub Action:
- Configure repository secrets with the environment variables listed above
- The Action will run automatically when new discussions are created
Edit the tags.json
file to customize the available labels:
{
"tags": [
{"name": "label-name", "description": "Label description", "color": "hex-color"}
]
}
MIT