-
Notifications
You must be signed in to change notification settings - Fork 189
145 lines (122 loc) · 5.26 KB
/
triage-all-open-issues.yml
File metadata and controls
145 lines (122 loc) · 5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: AI Triage - Process All Open Issues
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run mode - only list issues without processing'
required: false
default: false
type: boolean
max_issues:
description: 'Maximum number of issues to process (0 = all)'
required: false
default: '0'
type: string
permissions:
issues: write
contents: read
actions: write
jobs:
get_open_issues:
runs-on: ubuntu-latest
outputs:
issue_numbers: ${{ steps.get_issues.outputs.issue_numbers }}
total_count: ${{ steps.get_issues.outputs.total_count }}
steps:
- name: Get all open issues
id: get_issues
uses: actions/github-script@v6
with:
script: |
// Use Search API to filter issues at API level
const { data } = await github.rest.search.issuesAndPullRequests({
q: `repo:${context.repo.owner}/${context.repo.repo} is:issue is:open -label:ai-triaged -label:invalid`,
sort: 'created',
order: 'asc',
per_page: 100
});
const actualIssues = data.items;
let issuesToProcess = actualIssues;
const maxIssues = parseInt('${{ inputs.max_issues }}' || '0');
if (maxIssues > 0 && actualIssues.length > maxIssues) {
issuesToProcess = actualIssues.slice(0, maxIssues);
console.log(`Limiting to first ${maxIssues} issues out of ${actualIssues.length} total`);
}
const issueNumbers = issuesToProcess.map(issue => issue.number);
const totalCount = issuesToProcess.length;
console.log(`Found ${actualIssues.length} open issues, processing ${totalCount}:`);
issuesToProcess.forEach(issue => {
console.log(` #${issue.number}: ${issue.title}`);
});
core.setOutput('issue_numbers', JSON.stringify(issueNumbers));
core.setOutput('total_count', totalCount);
process_issues:
runs-on: ubuntu-latest
needs: get_open_issues
if: needs.get_open_issues.outputs.total_count > 0
strategy:
# Process issues one by one (max-parallel: 1)
max-parallel: 1
matrix:
issue_number: ${{ fromJSON(needs.get_open_issues.outputs.issue_numbers) }}
steps:
- name: Log current issue being processed
run: |
echo "🔄 Processing issue #${{ matrix.issue_number }}"
echo "Total issues to process: ${{ needs.get_open_issues.outputs.total_count }}"
- name: Check if dry run mode
if: inputs.dry_run == true
run: |
echo "🔍 DRY RUN MODE: Would process issue #${{ matrix.issue_number }}"
echo "Skipping actual triage processing"
- name: Trigger triage workflow for issue
if: inputs.dry_run != true
uses: actions/github-script@v6
with:
script: |
const issueNumber = '${{ matrix.issue_number }}';
try {
console.log(`Triggering triage workflow for issue #${issueNumber}`);
const response = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'triage-agent.yml',
ref: 'main',
inputs: {
issue_number: issueNumber
}
});
console.log(`✅ Successfully triggered triage workflow for issue #${issueNumber}`);
} catch (error) {
console.error(`❌ Failed to trigger triage workflow for issue #${issueNumber}:`, error);
core.setFailed(`Failed to process issue #${issueNumber}: ${error.message}`);
}
- name: Wait for workflow completion
if: inputs.dry_run != true
run: |
echo "⏳ Waiting for triage workflow to complete for issue #${{ matrix.issue_number }}..."
echo "Timeout: ${{ vars.TRIAGE_AGENT_TIMEOUT }} seconds"
sleep ${{ vars.TRIAGE_AGENT_TIMEOUT }} # Wait for triage workflow completion
summary:
runs-on: ubuntu-latest
needs: [get_open_issues, process_issues]
if: always()
steps:
- name: Print summary
run: |
echo "## Triage Processing Summary"
echo "Total open issues found: ${{ needs.get_open_issues.outputs.total_count }}"
if [ "${{ inputs.dry_run }}" == "true" ]; then
echo "Mode: DRY RUN (no actual processing performed)"
else
echo "Mode: FULL PROCESSING"
fi
if [ "${{ needs.process_issues.result }}" == "success" ]; then
echo "✅ All issues processed successfully"
elif [ "${{ needs.process_issues.result }}" == "failure" ]; then
echo "❌ Some issues failed to process"
elif [ "${{ needs.process_issues.result }}" == "skipped" ]; then
echo "⏭️ Processing was skipped (no open issues found)"
else
echo "⚠️ Processing completed with status: ${{ needs.process_issues.result }}"
fi