Skip to content

Commit f1f4860

Browse files
committed
Updated action.yml to parse server output properly
1 parent b62a414 commit f1f4860

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

action.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,21 @@ runs:
237237
echo "✅ Job completed successfully!"
238238
239239
# Check if result field exists and contains files
240-
if jq -e '.result.files' "$TEMP_FILE" > /dev/null; then
241-
echo "📦 Result with files found, preparing output..."
240+
if jq -e '.result' "$TEMP_FILE" > /dev/null; then
241+
echo "📦 Result field found, preparing output..."
242242
243-
# Extract just the result object into a new file
244-
jq '.result' "$TEMP_FILE" > "${TEMP_FILE}_result"
243+
# Check if result is a JSON string or already a JSON object
244+
RESULT_TYPE=$(jq -r '.result | type' "$TEMP_FILE")
245+
246+
if [ "$RESULT_TYPE" = "string" ]; then
247+
echo "🔧 Result is a JSON string, parsing it..."
248+
# Parse the JSON string in the result field
249+
jq -r '.result' "$TEMP_FILE" | jq '.' > "${TEMP_FILE}_result"
250+
else
251+
echo "🔧 Result is already a JSON object, extracting it..."
252+
# Extract the result object directly
253+
jq '.result' "$TEMP_FILE" > "${TEMP_FILE}_result"
254+
fi
245255
246256
# Verify the extracted result
247257
if jq -e '.files' "${TEMP_FILE}_result" > /dev/null; then
@@ -257,9 +267,25 @@ runs:
257267
exit 1
258268
fi
259269
else
260-
echo "❌ Error: Job completed but no result.files found in response"
270+
echo "❌ Error: Job completed but no result or result.files found in response"
261271
echo "📄 Response structure:"
262272
jq '.' "$TEMP_FILE"
273+
274+
# If result exists, show what it contains
275+
if jq -e '.result' "$TEMP_FILE" > /dev/null; then
276+
echo "📄 Result field content:"
277+
RESULT_TYPE=$(jq -r '.result | type' "$TEMP_FILE")
278+
echo "Result type: $RESULT_TYPE"
279+
280+
if [ "$RESULT_TYPE" = "string" ]; then
281+
echo "Result string content:"
282+
jq -r '.result' "$TEMP_FILE"
283+
else
284+
echo "Result object content:"
285+
jq '.result' "$TEMP_FILE"
286+
fi
287+
fi
288+
263289
rm -f "$TEMP_FILE"
264290
exit 1
265291
fi

0 commit comments

Comments
 (0)