4949 const labelNames = (issue.labels || []).map(label => label.name);
5050 core.setOutput('labels', JSON.stringify(labelNames));
5151
52- - name : Call Azure Function
53- id : call_azure_function
52+ - name : Start Triage Orchestration
53+ id : start_orchestration
5454 env :
5555 PAYLOAD : >-
5656 {
@@ -67,13 +67,14 @@ jobs:
6767 }
6868
6969 run : |
70- # Make the HTTP request with improved error handling and timeouts
71- echo "Making request to triage agent..."
70+ # Start the durable function orchestration
71+ echo "Starting triage orchestration..."
72+ echo "Payload size: $(echo "$PAYLOAD" | wc -c) bytes"
7273
73- # Add timeout handling and better error detection
74+ # Make the initial request to start orchestration
7475 set +e # Don't exit on curl failure
75- response=$(timeout ${{ vars.TRIAGE_AGENT_TIMEOUT }} curl \
76- --max-time 0 \
76+ response=$(curl \
77+ --max-time 60 \
7778 --connect-timeout 30 \
7879 --fail-with-body \
7980 --silent \
@@ -82,19 +83,16 @@ jobs:
8283 --header "Content-Type: application/json" \
8384 --request POST \
8485 --data "$PAYLOAD" \
85- ${{ secrets.TRIAGE_FUNCTION_LINK }} 2>&1)
86+ ${{ secrets.TRIAGE_START_ENDPOINT }} 2>&1)
8687
8788 curl_exit_code=$?
8889 set -e # Re-enable exit on error
8990
90- echo "Curl exit code: $curl_exit_code"
91+ echo "Start orchestration curl exit code: $curl_exit_code"
9192
92- # Check if curl command timed out or failed
93- if [ $curl_exit_code -eq 124 ]; then
94- echo "❌ Request timed out after 650 seconds"
95- exit 1
96- elif [ $curl_exit_code -ne 0 ]; then
97- echo "❌ Curl command failed with exit code: $curl_exit_code"
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"
9896 echo "Response: $response"
9997 exit 1
10098 fi
@@ -112,11 +110,115 @@ jobs:
112110 exit 1
113111 fi
114112
115- # Check if the request was successful
113+ # Check if the orchestration started successfully
116114 if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then
117- echo "✅ Azure Function call succeeded"
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
118128 else
119- echo "❌ Azure Function call failed with status code: $http_code"
129+ echo "❌ Failed to start orchestration with status code: $http_code"
120130 echo "Response: $response_body"
121131 exit 1
122132 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