@@ -49,50 +49,32 @@ jobs:
4949 local data="$3"
5050 local description="$4"
5151
52- echo "=== DEBUG: API Call Details ==="
53- echo "Description: $description"
54- echo "URL: $url"
55- echo "Method: $method"
56- echo "Data: $data"
52+ echo "Calling API: $description"
5753
54+ # Store response in a temporary file
5855 temp_file=$(mktemp)
59- http_code=$(curl -v -s -w "%{http_code}" \
56+
57+ # Execute curl with minimal output
58+ response=$(curl -s \
6059 --request "$method" "$url" \
6160 --header "Authorization: Bearer ${{ steps.bytebase-login.outputs.token }}" \
6261 --header "Content-Type: application/json" \
6362 --data "$data" \
64- -o "$temp_file" 2>&1)
65-
66- echo "=== DEBUG: Response Details ==="
67- echo "HTTP Status: $http_code"
68- echo "Response body:"
69- cat "$temp_file"
70- echo "==========================="
63+ --write-out "\n%{http_code}" \
64+ 2>/dev/null)
7165
72- if [[ $http_code -lt 200 || $http_code -ge 300 ]]; then
73- echo "Error: Failed $description. Status: $http_code"
74- cat "$temp_file"
75- rm "$temp_file"
76- return 1
77- fi
66+ http_code=$(echo "$response" | tail -n1)
67+ body=$(echo "$response" | sed '$d')
7868
79- if [[ ! -s "$temp_file" ]]; then
80- echo "Error: Empty response from server"
81- rm "$temp_file"
82- return 1
83- fi
69+ echo "Status code: $http_code"
8470
85- # Simple one-line JSON validation
86- if ! python3 -c "import json,sys; json.load(open('$temp_file'))" 2>/dev/null; then
87- echo "Error: Invalid JSON response"
88- echo "Response content:"
89- cat "$temp_file"
90- rm "$temp_file"
71+ if [[ $http_code -lt 200 || $http_code -ge 300 ]]; then
72+ echo "Error: Failed $description"
73+ echo "Response: $body"
9174 return 1
9275 fi
9376
94- cat "$temp_file"
95- rm "$temp_file"
77+ echo "$body"
9678 return 0
9779 }
9880
@@ -136,7 +118,8 @@ jobs:
136118
137119 for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
138120 echo "Processing $file"
139- SQL_CONTENT=$(cat "$file" | python3 -c "import sys,base64,json; content=sys.stdin.read(); encoded=base64.b64encode(content.encode()).decode(); print(json.dumps(encoded)[1:-1])") echo "SQL_CONTENT=$SQL_CONTENT" >> $GITHUB_ENV
121+ SQL_CONTENT=$(cat "$file" | python3 -c "import sys,base64,json; content=sys.stdin.read(); encoded=base64.b64encode(content.encode()).decode(); print(json.dumps(encoded)[1:-1])")
122+ echo "SQL_CONTENT=$SQL_CONTENT" >> $GITHUB_ENV
140123 STEP_ID=$(python3 -c "import uuid; print(str(uuid.uuid4()))")
141124 echo "STEP_ID=$STEP_ID" >> $GITHUB_ENV
142125 BASE_URL="${{ steps.bytebase-login.outputs.api_url }}"
0 commit comments