-
Notifications
You must be signed in to change notification settings - Fork 6
Add automatic issue triage workflow with AI-based labeling #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
schlessera
merged 12 commits into
main
from
copilot/fix-1570774-181716041-20411eca-34f5-409a-a217-dd2c5535347a
Dec 12, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8116535
Initial plan
Copilot 4182ada
Add issue triage workflow with automatic labeling
Copilot 774bd2d
Add issue-triage workflow to sync list
Copilot 6245837
Refactor issue triage workflow to reduce duplication and improve accu…
Copilot 64acef4
Reimplement issue triage using AI inference action
Copilot 7b6dc58
Fix AI inference output handling and implement batch triage via workf…
Copilot ea56112
Split workflow into reusable and calling workflows
Copilot 46601c2
Remove unused process_unlabeled input parameter
Copilot 4f7c000
Apply suggestions
swissspidy 6466929
Merge branch 'main' into copilot/fix-1570774-181716041-20411eca-34f5-…
swissspidy df39bed
Merge branch 'main' into copilot/fix-1570774-181716041-20411eca-34f5-…
swissspidy 2336b80
Merge branch 'main' into copilot/fix-1570774-181716041-20411eca-34f5-…
schlessera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| name: Issue Triage | ||
|
|
||
| 'on': | ||
| issues: | ||
| types: [opened] | ||
| workflow_dispatch: | ||
| inputs: | ||
| issue_number: | ||
| description: 'Issue number to triage (leave empty to process all)' | ||
| required: false | ||
| type: string | ||
|
|
||
| jobs: | ||
| issue-triage: | ||
| uses: wp-cli/.github/.github/workflows/reusable-issue-triage.yml@main | ||
| with: | ||
| issue_number: ${{ github.event_name == 'workflow_dispatch' && inputs.issue_number || github.event.issue.number }} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,329 @@ | ||
| --- | ||
| name: Issue Triage | ||
|
|
||
| 'on': | ||
| workflow_call: | ||
| inputs: | ||
| issue_number: | ||
| description: 'Issue number to triage (leave empty to process all)' | ||
| required: false | ||
| type: string | ||
|
|
||
| permissions: | ||
| issues: write | ||
| contents: read | ||
|
|
||
| jobs: | ||
| triage-new-issue: | ||
| name: Triage New Issue | ||
| if: github.event_name == 'issues' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get available labels | ||
| id: get-labels | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const labels = await github.rest.issues.listLabelsForRepo({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| per_page: 100 | ||
| }); | ||
| const labelNames = labels.data.map(label => label.name); | ||
| return labelNames.join(', '); | ||
|
|
||
| - name: Set environment variables | ||
| env: | ||
| ISSUE_TITLE: ${{ github.event.issue.title }} | ||
| ISSUE_BODY: ${{ github.event.issue.body }} | ||
| LABELS_RESULT: ${{ steps.get-labels.outputs.result }} | ||
| run: | | ||
| { | ||
| echo "AVAILABLE_LABELS=${LABELS_RESULT}" | ||
| echo "ISSUE_TITLE=${ISSUE_TITLE}" | ||
| echo "ISSUE_BODY<<EOF" | ||
| echo "${ISSUE_BODY}" | ||
| echo "EOF" | ||
| } >> "$GITHUB_ENV" | ||
|
|
||
| - name: Analyze issue with AI | ||
| id: ai-triage | ||
| uses: actions/ai-inference@v1 | ||
| with: | ||
| prompt: | | ||
| ## Role | ||
|
|
||
| You are an issue triage assistant. Analyze the current GitHub | ||
| issue and identify the most appropriate existing labels. Use the | ||
| available tools to gather information; do not ask for information | ||
| to be provided. | ||
|
|
||
| ## Guidelines | ||
|
|
||
| - Only use labels that are from the list of available labels. | ||
| - You can choose multiple labels to apply. | ||
| - When generating shell commands, you **MUST NOT** use command | ||
| substitution with `$(...)`, `<(...)`, or `>(...)`. This is a | ||
| security measure to prevent unintended command execution. | ||
|
|
||
| ## Input Data | ||
|
|
||
| **Available Labels** (comma-separated): | ||
| ``` | ||
| ${{ env.AVAILABLE_LABELS }} | ||
| ``` | ||
|
|
||
| **Issue Title**: | ||
| ``` | ||
| ${{ env.ISSUE_TITLE }} | ||
| ``` | ||
|
|
||
| **Issue Body**: | ||
| ``` | ||
| ${{ env.ISSUE_BODY }} | ||
| ``` | ||
|
|
||
| ## Steps | ||
|
|
||
| 1. Review the issue title, issue body, and available labels | ||
| provided above. | ||
|
|
||
| 2. Based on the issue title and issue body, classify the issue | ||
| and choose all appropriate labels from the list of available | ||
| labels. | ||
|
|
||
| 3. Return only the selected labels as a comma-separated list, | ||
| with no additional text or explanation. For example: | ||
| ``` | ||
| label1, label2, label3 | ||
| ``` | ||
|
|
||
| - name: Apply labels | ||
| if: steps.ai-triage.outputs.response != '' | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| AI_RESPONSE: ${{ steps.ai-triage.outputs.response }} | ||
| with: | ||
| script: | | ||
| const response = process.env.AI_RESPONSE; | ||
| if (!response || response.trim() === '') { | ||
| console.log('No labels selected by AI'); | ||
| return; | ||
| } | ||
|
|
||
| const labels = response.split(',') | ||
| .map(l => l.trim()) | ||
| .filter(l => l.length > 0); | ||
|
|
||
| if (labels.length > 0) { | ||
| console.log(`Applying labels: ${labels.join(', ')}`); | ||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| labels: labels | ||
| }); | ||
| } else { | ||
| console.log('No valid labels to apply'); | ||
| } | ||
|
|
||
| triage-unlabeled-issues: | ||
| name: Triage Unlabeled Issues | ||
| if: | | ||
| github.event_name == 'workflow_dispatch' && | ||
| inputs.issue_number == '' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Find and dispatch triage for unlabeled issues | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| // Get all open issues | ||
| const issues = await github.paginate( | ||
| github.rest.issues.listForRepo, | ||
| { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| state: 'open', | ||
| per_page: 100 | ||
| } | ||
| ); | ||
|
|
||
| console.log(`Found ${issues.length} open issues`); | ||
|
|
||
| // Filter issues without labels | ||
| const unlabeledIssues = issues.filter(issue => | ||
| !issue.pull_request && issue.labels.length === 0 | ||
| ); | ||
|
|
||
| console.log( | ||
| `Found ${unlabeledIssues.length} unlabeled issues` | ||
| ); | ||
|
|
||
| if (unlabeledIssues.length === 0) { | ||
| console.log('No unlabeled issues to process'); | ||
| return; | ||
| } | ||
|
|
||
| // Dispatch triage workflow for each unlabeled issue | ||
| for (const issue of unlabeledIssues) { | ||
| console.log( | ||
| `Dispatching triage for issue #${issue.number}: ` + | ||
| `"${issue.title}"` | ||
| ); | ||
|
|
||
| try { | ||
| await github.rest.actions.createWorkflowDispatch({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| workflow_id: 'issue-triage.yml', | ||
| ref: context.ref || 'main', | ||
| inputs: { | ||
| issue_number: issue.number.toString() | ||
| } | ||
| }); | ||
| } catch (error) { | ||
| console.error( | ||
| `Failed to dispatch triage for issue #${issue.number}: ` + | ||
| `${error.message}` | ||
| ); | ||
| } | ||
|
|
||
| // Add a small delay to avoid rate limiting | ||
| await new Promise(resolve => setTimeout(resolve, 100)); | ||
| } | ||
|
|
||
| console.log('Finished dispatching triage workflows'); | ||
|
|
||
| triage-single-issue: | ||
| name: Triage Single Issue | ||
| if: | | ||
| github.event_name == 'workflow_dispatch' && | ||
| inputs.issue_number != '' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get available labels | ||
| id: get-labels | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const labels = await github.rest.issues.listLabelsForRepo({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| per_page: 100 | ||
| }); | ||
| const labelNames = labels.data.map(label => label.name); | ||
| return labelNames.join(', '); | ||
|
|
||
| - name: Get issue details | ||
| id: get-issue | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const issue = await github.rest.issues.get({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: parseInt('${{ inputs.issue_number }}') | ||
| }); | ||
| return { | ||
| title: issue.data.title, | ||
| body: issue.data.body || '' | ||
| }; | ||
|
|
||
| - name: Set environment variables | ||
| env: | ||
| ISSUE_TITLE: ${{ fromJSON(steps.get-issue.outputs.result).title }} | ||
| ISSUE_BODY: ${{ fromJSON(steps.get-issue.outputs.result).body }} | ||
| LABELS_RESULT: ${{ steps.get-labels.outputs.result }} | ||
| run: | | ||
| { | ||
| echo "AVAILABLE_LABELS=${LABELS_RESULT}" | ||
| echo "ISSUE_TITLE=${ISSUE_TITLE}" | ||
| echo "ISSUE_BODY<<EOF" | ||
| echo "${ISSUE_BODY}" | ||
| echo "EOF" | ||
| } >> "$GITHUB_ENV" | ||
|
|
||
| - name: Analyze issue with AI | ||
| id: ai-triage | ||
| uses: actions/ai-inference@v1 | ||
| with: | ||
| prompt: | | ||
| ## Role | ||
|
|
||
| You are an issue triage assistant. Analyze the current GitHub | ||
| issue and identify the most appropriate existing labels. Use the | ||
| available tools to gather information; do not ask for information | ||
| to be provided. | ||
|
|
||
| ## Guidelines | ||
|
|
||
| - Only use labels that are from the list of available labels. | ||
| - You can choose multiple labels to apply. | ||
| - When generating shell commands, you **MUST NOT** use command | ||
| substitution with `$(...)`, `<(...)`, or `>(...)`. This is a | ||
| security measure to prevent unintended command execution. | ||
|
|
||
| ## Input Data | ||
|
|
||
| **Available Labels** (comma-separated): | ||
| ``` | ||
| ${{ env.AVAILABLE_LABELS }} | ||
| ``` | ||
|
|
||
| **Issue Title**: | ||
| ``` | ||
| ${{ env.ISSUE_TITLE }} | ||
| ``` | ||
|
|
||
| **Issue Body**: | ||
| ``` | ||
| ${{ env.ISSUE_BODY }} | ||
| ``` | ||
|
|
||
| ## Steps | ||
|
|
||
| 1. Review the issue title, issue body, and available labels | ||
| provided above. | ||
|
|
||
| 2. Based on the issue title and issue body, classify the issue | ||
| and choose all appropriate labels from the list of available | ||
| labels. | ||
|
|
||
| 3. Return only the selected labels as a comma-separated list, | ||
| with no additional text or explanation. For example: | ||
| ``` | ||
| label1, label2, label3 | ||
| ``` | ||
|
|
||
| - name: Apply labels | ||
| if: steps.ai-triage.outputs.response != '' | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| AI_RESPONSE: ${{ steps.ai-triage.outputs.response }} | ||
| ISSUE_NUMBER: ${{ inputs.issue_number }} | ||
| with: | ||
| script: | | ||
| const response = process.env.AI_RESPONSE; | ||
| const issueNumber = parseInt(process.env.ISSUE_NUMBER); | ||
|
|
||
| if (!response || response.trim() === '') { | ||
| console.log('No labels selected by AI'); | ||
| return; | ||
| } | ||
|
|
||
| const labels = response.split(',') | ||
| .map(l => l.trim()) | ||
| .filter(l => l.length > 0); | ||
|
|
||
| if (labels.length > 0) { | ||
| console.log(`Applying labels: ${labels.join(', ')}`); | ||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issueNumber, | ||
| labels: labels | ||
| }); | ||
| } else { | ||
| console.log('No valid labels to apply'); | ||
| } | ||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.