|
1 | | -# discussions |
2 | | -testing discussions feature |
| 1 | +# GitHub Discussion Auto-Labeler |
| 2 | + |
| 3 | +Automatically labels GitHub discussions using AI to analyze content and apply appropriate tags. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Automatically applies labels to new GitHub discussions |
| 8 | +- Uses Azure OpenAI for content analysis |
| 9 | +- Supports both GitHub token and GitHub App authentication |
| 10 | +- Can be run locally or as a GitHub Action |
| 11 | +- Includes a utility to create repository labels |
| 12 | + |
| 13 | +## Setup |
| 14 | + |
| 15 | +### Prerequisites |
| 16 | + |
| 17 | +- Python 3.10+ |
| 18 | +- GitHub token or GitHub App credentials |
| 19 | +- Azure OpenAI service (for AI-based labeling) |
| 20 | + |
| 21 | +### Installation |
| 22 | + |
| 23 | +1. Clone this repository |
| 24 | +2. Install dependencies: |
| 25 | + ```bash |
| 26 | + pip install -r requirements.txt |
| 27 | + ``` |
| 28 | +3. Copy `.env.sample` to `.env` and fill in your credentials |
| 29 | + |
| 30 | +### Environment Variables |
| 31 | + |
| 32 | +| Variable | Description | |
| 33 | +|----------|-------------| |
| 34 | +| `TOKEN` | GitHub personal access token | |
| 35 | +| `APP_ID` | GitHub App ID | |
| 36 | +| `APP_PRIVATE_KEY` | GitHub App private key (content as string) | |
| 37 | +| `APP_INSTALLATION_ID` | GitHub App installation ID | |
| 38 | +| `DEFAULT_REPO` | Repository to monitor in format `owner/repo` | |
| 39 | +| `AZURE_OPENAI_ENDPOINT` | Azure OpenAI API endpoint | |
| 40 | +| `AZURE_OPENAI_KEY` | Azure OpenAI API key | |
| 41 | +| `AZURE_OPENAI_API_VERSION` | Azure OpenAI API version | |
| 42 | +| `RUN_INTERVAL_MINUTES` | How often to check for new discussions (in minutes) | |
| 43 | + |
| 44 | +## Usage |
| 45 | + |
| 46 | +### Running Locally |
| 47 | + |
| 48 | +To run the script locally and continuously monitor for new discussions: |
| 49 | + |
| 50 | +```bash |
| 51 | +python basic.py |
| 52 | +``` |
| 53 | + |
| 54 | +### Creating Repository Labels |
| 55 | + |
| 56 | +To create the labels defined in `tags.json` in your repository: |
| 57 | + |
| 58 | +```bash |
| 59 | +python new-labels.py |
| 60 | +``` |
| 61 | + |
| 62 | +### GitHub Action |
| 63 | + |
| 64 | +This repo includes a GitHub Action workflow that automatically runs when new discussions are created. |
| 65 | + |
| 66 | +To set up the GitHub Action: |
| 67 | +1. Configure repository secrets with the environment variables listed above |
| 68 | +2. The Action will run automatically when new discussions are created |
| 69 | + |
| 70 | +## Customizing Labels |
| 71 | + |
| 72 | +Edit the `tags.json` file to customize the available labels: |
| 73 | + |
| 74 | +```json |
| 75 | +{ |
| 76 | + "tags": [ |
| 77 | + {"name": "label-name", "description": "Label description", "color": "hex-color"} |
| 78 | + ] |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +## License |
| 83 | + |
| 84 | +MIT |
0 commit comments