build: added action to automatically triage issues #6
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Issue Triage with Gemini | |
| on: | |
| issues: | |
| types: [opened, edited] | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| title: | |
| description: 'Mock Issue Title' | |
| default: 'Test Issue' | |
| body: | |
| description: 'Mock Issue Body' | |
| default: 'This is a test issue description.' | |
| jobs: | |
| triage: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Run Triage Script | |
| id: run_script | |
| env: | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| ISSUE_TITLE: ${{ github.event.issue.title || github.event.pull_request.title || github.event.inputs.title }} | |
| ISSUE_BODY: ${{ github.event.issue.body || github.event.pull_request.body || github.event.inputs.body }} | |
| run: | | |
| labels=$(python .github/scripts/triage_issue.py) | |
| echo "labels=$labels" >> $GITHUB_OUTPUT | |
| - name: Apply Labels | |
| if: steps.run_script.outputs.labels != '' && (github.event.issue.number || github.event.pull_request.number) | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| ISSUE_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }} | |
| run: | | |
| # Convert comma-separated labels to gh command arguments | |
| IFS=',' read -ra ADDR <<< "${{ steps.run_script.outputs.labels }}" | |
| for i in "${ADDR[@]}"; do | |
| # Trim whitespace | |
| label=$(echo "$i" | xargs) | |
| # Only add priority labels as requested | |
| if [[ "$label" == priority:* ]]; then | |
| gh issue edit "$ISSUE_NUMBER" --add-label "$label" | |
| fi | |
| done |