1- name : AI Triage - Label and Comment on New Issues
1+ name : AI Triage
22on :
33 issues :
44 types : [opened]
88 description : ' Issue number to triage (manual run). e.g. 123'
99 required : true
1010
11+ run-name : >-
12+ AI Triage for Issue #${{ github.event.issue.number || github.event.inputs.issue_number }}
13+
1114permissions :
1215 issues : write
1316 contents : read
4952 const labelNames = (issue.labels || []).map(label => label.name);
5053 core.setOutput('labels', JSON.stringify(labelNames));
5154
52- - name : Start Triage Orchestration
53- id : start_orchestration
55+ - name : Call Azure Function
56+ id : call_azure_function
5457 env :
5558 PAYLOAD : >-
5659 {
@@ -67,14 +70,13 @@ jobs:
6770 }
6871
6972 run : |
70- # Start the durable function orchestration
71- echo "Starting triage orchestration..."
72- echo "Payload size: $(echo "$PAYLOAD" | wc -c) bytes"
73+ # Make the HTTP request with improved error handling and timeouts
74+ echo "Making request to triage agent..."
7375
74- # Make the initial request to start orchestration
76+ # Add timeout handling and better error detection
7577 set +e # Don't exit on curl failure
76- response=$(curl \
77- --max-time 60 \
78+ response=$(timeout ${{ vars.TRIAGE_AGENT_TIMEOUT }} curl \
79+ --max-time 0 \
7880 --connect-timeout 30 \
7981 --fail-with-body \
8082 --silent \
@@ -83,16 +85,19 @@ jobs:
8385 --header "Content-Type: application/json" \
8486 --request POST \
8587 --data "$PAYLOAD" \
86- ${{ secrets.TRIAGE_START_ENDPOINT }} 2>&1)
88+ ${{ secrets.TRIAGE_FUNCTION_LINK }} 2>&1)
8789
8890 curl_exit_code=$?
8991 set -e # Re-enable exit on error
9092
91- echo "Start orchestration curl exit code: $curl_exit_code"
93+ echo "Curl exit code: $curl_exit_code"
9294
93- # Check if curl command failed
94- if [ $curl_exit_code -ne 0 ]; then
95- echo "❌ Failed to start orchestration with exit code: $curl_exit_code"
95+ # Check if curl command timed out or failed
96+ if [ $curl_exit_code -eq 124 ]; then
97+ echo "❌ Request timed out after 650 seconds"
98+ exit 1
99+ elif [ $curl_exit_code -ne 0 ]; then
100+ echo "❌ Curl command failed with exit code: $curl_exit_code"
96101 echo "Response: $response"
97102 exit 1
98103 fi
@@ -110,115 +115,11 @@ jobs:
110115 exit 1
111116 fi
112117
113- # Check if the orchestration started successfully
118+ # Check if the request was successful
114119 if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then
115- echo "✅ Triage orchestration started successfully"
116- echo "Response: $response_body"
117-
118- # Extract instance ID from response (assuming JSON response with instanceId field)
119- instance_id=$(echo "$response_body" | grep -o '"instanceId":"[^"]*"' | cut -d'"' -f4)
120- if [ -z "$instance_id" ]; then
121- echo "❌ Failed to extract instance ID from response"
122- echo "Response body: $response_body"
123- exit 1
124- fi
125-
126- echo "Instance ID: $instance_id"
127- echo "instance_id=$instance_id" >> $GITHUB_OUTPUT
120+ echo "✅ Azure Function call succeeded"
128121 else
129- echo "❌ Failed to start orchestration with status code: $http_code"
122+ echo "❌ Azure Function call failed with status code: $http_code"
130123 echo "Response: $response_body"
131124 exit 1
132125 fi
133-
134- - name : Poll Orchestration Status
135- id : poll_status
136- run : |
137- # Poll the orchestration status until completion
138- instance_id="${{ steps.start_orchestration.outputs.instance_id }}"
139- echo "Polling status for instance: $instance_id"
140-
141- max_attempts=120 # Maximum number of polling attempts (10 minutes with 5-second intervals)
142- attempt=0
143-
144- while [ $attempt -lt $max_attempts ]; do
145- attempt=$((attempt + 1))
146- echo "Polling attempt $attempt/$max_attempts..."
147-
148- # Make status check request
149- set +e # Don't exit on curl failure
150- # Safely replace the {instanceId} placeholder using bash parameter expansion
151- status_url="${{ secrets.TRIAGE_STATUS_ENDPOINT }}"
152- status_url="${status_url//\{instanceId\}/$instance_id}"
153-
154- response=$(curl \
155- --max-time 30 \
156- --connect-timeout 15 \
157- --fail-with-body \
158- --silent \
159- --show-error \
160- --write-out "HTTPSTATUS:%{http_code}" \
161- --request GET \
162- "$status_url" 2>&1)
163-
164- curl_exit_code=$?
165- set -e # Re-enable exit on error
166-
167- if [ $curl_exit_code -ne 0 ]; then
168- echo "❌ Status check failed with exit code: $curl_exit_code"
169- echo "Response: $response"
170- sleep 5
171- continue
172- fi
173-
174- # Extract HTTP status code and response body
175- http_code=$(echo "$response" | grep -o "HTTPSTATUS:[0-9]*" | cut -d: -f2)
176- response_body=$(echo "$response" | sed 's/HTTPSTATUS:[0-9]*$//')
177-
178- echo "Status check HTTP code: $http_code"
179-
180- if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then
181- echo "Status response: $response_body"
182-
183- # Check if orchestration is complete (using runtimeStatus field from actual response schema)
184- runtime_status=$(echo "$response_body" | grep -o '"runtimeStatus":"[^"]*"' | cut -d'"' -f4)
185-
186- if [ "$runtime_status" = "Completed" ] || [ "$runtime_status" = "completed" ]; then
187- echo "✅ Triage orchestration completed successfully"
188- # Extract and display output if available
189- output=$(echo "$response_body" | grep -o '"output":[^,}]*' | cut -d':' -f2-)
190- if [ "$output" != "null" ] && [ -n "$output" ]; then
191- echo "Orchestration output: $output"
192- fi
193- exit 0
194- elif [ "$runtime_status" = "Failed" ] || [ "$runtime_status" = "failed" ]; then
195- echo "❌ Triage orchestration failed"
196- echo "Final response: $response_body"
197- # Extract and display output for error details if available
198- output=$(echo "$response_body" | grep -o '"output":[^,}]*' | cut -d':' -f2-)
199- if [ "$output" != "null" ] && [ -n "$output" ]; then
200- echo "Error details: $output"
201- fi
202- exit 1
203- elif [ "$runtime_status" = "Running" ] || [ "$runtime_status" = "running" ] || [ "$runtime_status" = "Pending" ] || [ "$runtime_status" = "pending" ]; then
204- echo "Orchestration status: $runtime_status, waiting..."
205- # Display last updated time for better monitoring
206- last_updated=$(echo "$response_body" | grep -o '"lastUpdatedAt":"[^"]*"' | cut -d'"' -f4)
207- if [ -n "$last_updated" ]; then
208- echo "Last updated: $last_updated"
209- fi
210- sleep 5
211- else
212- echo "Unknown runtime status: $runtime_status, continuing to poll..."
213- echo "Full response: $response_body"
214- sleep 5
215- fi
216- else
217- echo "❌ Status check returned HTTP $http_code"
218- echo "Response: $response_body"
219- sleep 5
220- fi
221- done
222-
223- echo "❌ Orchestration polling timed out after $max_attempts attempts"
224- exit 1
0 commit comments