Skip to content

Commit 014ce8e

Browse files
committed
Added action.yml
1 parent 5d824be commit 014ce8e

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

action.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,48 @@ runs:
8686
TEMP_FILE=$(mktemp)
8787
8888
# Make the API call and save response
89-
response=$(curl -s -w "%{http_code}" -o "$TEMP_FILE" "$ENDPOINT_URL?url=$REPO_URL&source_branch=$SOURCE_BRANCH&target_branch=$TARGET_BRANCH")
89+
response=$(curl -s -w "%{http_code}" -o "$TEMP_FILE" "$ENDPOINT_URL?url=$REPO_URL&source_branch=$SOURCE_BRANCH&target_branch=$TARGET_BRANCH&output_format=$OUTPUT_FORMAT")
9090
http_code=${response: -3}
9191
92-
if [ "$http_code" != "200" ]; then
92+
echo "API response status code: $http_code"
93+
94+
if [ "$http_code" = "404" ]; then
95+
echo "No documentation files were generated for this repository/branch combination."
96+
echo "This might be because:"
97+
echo "- No changes were detected between the source and target branches"
98+
echo "- The repository or branches don't exist or are not accessible"
99+
echo "- No analyzable code files were found"
100+
101+
# Check if response contains error details
102+
if jq -e '.detail' "$TEMP_FILE" > /dev/null 2>&1; then
103+
echo "Server message: $(jq -r '.detail' "$TEMP_FILE")"
104+
else
105+
echo "Server response:"
106+
cat "$TEMP_FILE"
107+
fi
108+
109+
# Create empty response for graceful handling
110+
echo '{"files": {}}' > "$TEMP_FILE"
111+
echo "response_file=$TEMP_FILE" >> $GITHUB_OUTPUT
112+
exit 0
113+
elif [ "$http_code" != "200" ]; then
93114
echo "Error: API call failed with status code $http_code"
115+
echo "Response content:"
94116
cat "$TEMP_FILE"
117+
118+
# Try to parse as JSON for better error message
119+
if jq -e '.detail' "$TEMP_FILE" > /dev/null 2>&1; then
120+
echo "Error details: $(jq -r '.detail' "$TEMP_FILE")"
121+
fi
122+
95123
rm -f "$TEMP_FILE"
96124
exit 1
97125
fi
98126
99127
# Check if response is valid JSON
100128
if ! jq empty "$TEMP_FILE" 2>/dev/null; then
101129
echo "Error: Invalid JSON response"
130+
echo "Response content:"
102131
cat "$TEMP_FILE"
103132
rm -f "$TEMP_FILE"
104133
exit 1

0 commit comments

Comments
 (0)