feat(triage): improve automated issue triage workflows (#2778)

This commit is contained in:
Jerop Kipruto 2025-06-30 22:59:46 -04:00 committed by GitHub
parent 84355bb447
commit e10c208fbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 55 additions and 33 deletions

View File

@ -23,19 +23,10 @@ jobs:
app-id: ${{ secrets.APP_ID }} app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }} private-key: ${{ secrets.PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ steps.generate_token.outputs.token }}
- name: Run Gemini Issue Triage - name: Run Gemini Issue Triage
uses: google-gemini/gemini-cli-action@111dadaecabd309baba60f56f2b520c52c0f9a47 uses: google-gemini/gemini-cli-action@41c0f1b3cbd1a0b284251bd1aac034edd07a3a2f
env: env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
REPOSITORY: ${{ github.repository }}
with: with:
version: 0.1.8-rc.0 version: 0.1.8-rc.0
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
@ -48,16 +39,23 @@ jobs:
"run_shell_command(gh label list)", "run_shell_command(gh label list)",
"run_shell_command(gh issue edit)", "run_shell_command(gh issue edit)",
"run_shell_command(gh issue list)" "run_shell_command(gh issue list)"
], ]
} }
prompt: | prompt: |
You are an issue triage assistant. Analyze the current GitHub issue and apply the most appropriate existing labels. You are an issue triage assistant. Analyze the current GitHub issue and apply the most appropriate existing labels.
Steps: Steps:
1. Run: `gh label list --limit 100` to get all available labels. 1. Run: `gh label list --repo ${{ github.repository }} --limit 100` to get all available labels.
2. Review the issue title and body provided in the environment variables. 2. Review the issue title and body provided in the environment variables.
3. Select the most relevant labels from the existing labels, focusing on kind/*, area/*, and priority/*. 3. Select the most relevant labels from the existing labels, focusing on kind/*, area/*, and priority/*.
4. Apply the selected labels to this issue using: `gh issue edit ISSUE_NUMBER --add-label "label1,label2"` 4. Apply the selected labels to this issue using: `gh issue edit ${{ github.event.issue.number }} --repo ${{ github.repository }} --add-label "label1,label2"`
5. If the issue has a "status/need-triage" label, remove it after applying the appropriate labels: `gh issue edit ${{ github.event.issue.number }} --repo ${{ github.repository }} --remove-label "status/need-triage"`
Guidelines:
- Only use labels that already exist in the repository.
- Do not add comments or modify the issue content.
- Triage only the current issue.
- Assign all applicable kind/*, area/*, and priority/* labels based on the issue content.
Guidelines: Guidelines:
- Only use labels that already exist in the repository. - Only use labels that already exist in the repository.

View File

@ -21,28 +21,33 @@ jobs:
app-id: ${{ secrets.APP_ID }} app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }} private-key: ${{ secrets.PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ steps.generate_token.outputs.token }}
- name: Find untriaged issues - name: Find untriaged issues
id: find_issues id: find_issues
env: env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: | run: |
echo "🔍 Finding issues without labels..."
NO_LABEL_ISSUES=$(gh issue list --repo ${{ github.repository }} --search "is:open is:issue no:label" --json number,title,body) NO_LABEL_ISSUES=$(gh issue list --repo ${{ github.repository }} --search "is:open is:issue no:label" --json number,title,body)
NEEDS_TRIAGE_ISSUES=$(gh issue list --repo ${{ github.repository }} --search "is:open is:issue label:\"status/needs-triage\"" --json number,title,body)
ISSUES=$(echo "$NO_LABEL_ISSUES" "$NEEDS_TRIAGE_ISSUES" | jq -c -s 'add | unique_by(.number)') echo "🏷️ Finding issues that need triage..."
NEED_TRIAGE_ISSUES=$(gh issue list --repo ${{ github.repository }} --search "is:open is:issue label:\"status/need-triage\"" --json number,title,body)
echo "🔄 Merging and deduplicating issues..."
ISSUES=$(echo "$NO_LABEL_ISSUES" "$NEED_TRIAGE_ISSUES" | jq -c -s 'add | unique_by(.number)')
echo "📝 Setting output for GitHub Actions..."
echo "issues_to_triage=$ISSUES" >> "$GITHUB_OUTPUT" echo "issues_to_triage=$ISSUES" >> "$GITHUB_OUTPUT"
echo "💾 Writing issues to temporary file for Gemini CLI..."
echo "$ISSUES" > /tmp/issues_to_triage.json
echo "✅ Found $(echo "$ISSUES" | jq 'length') issues to triage! 🎯"
- name: Run Gemini Issue Triage - name: Run Gemini Issue Triage
if: steps.find_issues.outputs.issues_to_triage != '[]' if: steps.find_issues.outputs.issues_to_triage != '[]'
uses: google-gemini/gemini-cli-action@111dadaecabd309baba60f56f2b520c52c0f9a47 uses: google-gemini/gemini-cli-action@41c0f1b3cbd1a0b284251bd1aac034edd07a3a2f
env: env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
ISSUES_TO_TRIAGE: ${{ steps.find_issues.outputs.issues_to_triage }}
REPOSITORY: ${{ github.repository }}
with: with:
version: 0.1.8-rc.0 version: 0.1.8-rc.0
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
@ -54,19 +59,38 @@ jobs:
"coreTools": [ "coreTools": [
"run_shell_command(gh label list)", "run_shell_command(gh label list)",
"run_shell_command(gh issue edit)", "run_shell_command(gh issue edit)",
"run_shell_command(gh issue list)" "run_shell_command(gh issue list)",
], "run_shell_command(cat /tmp/issues_to_triage.json)"
]
} }
prompt: | prompt: |
You are an issue triage assistant. Analyze issues and apply appropriate labels. You are an issue triage assistant. Analyze issues and apply appropriate labels ONE AT A TIME.
Repository: ${{ github.repository }}
Steps: Steps:
1. Run: `gh label list --limit 100` 1. Run: `gh label list --repo ${{ github.repository }} --limit 100` to see available labels
2. Check environment variable: $ISSUES_TO_TRIAGE (JSON array of issues) 2. Run: `cat /tmp/issues_to_triage.json` to get the issues that need triaging
3. For each issue, apply labels: `gh issue edit ISSUE_NUMBER --add-label "label1,label2"` 3. Parse the JSON array from step 2 and for EACH INDIVIDUAL issue, apply appropriate labels using separate commands:
- `gh issue edit ISSUE_NUMBER --repo ${{ github.repository }} --add-label "label1"`
- `gh issue edit ISSUE_NUMBER --repo ${{ github.repository }} --add-label "label2"`
- Continue for each label separately
IMPORTANT: Label each issue individually, one command per issue, one label at a time if needed.
Guidelines: Guidelines:
- Only use existing repository labels - Only use existing repository labels from step 1
- Do not add comments - Do not add comments to issues
- Triage each issue independently - Triage each issue independently based on title and body content
- Focus on: kind/*, area/*, priority/* labels - Focus on applying: kind/* (bug/enhancement/documentation), area/* (core/cli/testing/windows), and priority/* labels
- If an issue has insufficient information, consider applying "status/need-information"
- After applying appropriate labels to an issue, remove the "status/need-triage" label if present: `gh issue edit ISSUE_NUMBER --repo ${{ github.repository }} --remove-label "status/need-triage"`
- Execute one `gh issue edit` command per issue, wait for success before proceeding to the next
Example triage logic:
- Issues with "bug", "error", "broken" → kind/bug
- Issues with "feature", "enhancement", "improve" → kind/enhancement
- Issues about Windows/performance → area/windows, area/performance
- Critical bugs → priority/p0, other bugs → priority/p1, enhancements → priority/p2
Process each issue sequentially and confirm each labeling operation before moving to the next issue.