diff --git a/.github/workflows/bb-export.yml b/.github/workflows/bb-export.yml index 248264f..c94a4e8 100644 --- a/.github/workflows/bb-export.yml +++ b/.github/workflows/bb-export.yml @@ -49,50 +49,32 @@ jobs: local data="$3" local description="$4" - echo "=== DEBUG: API Call Details ===" - echo "Description: $description" - echo "URL: $url" - echo "Method: $method" - echo "Data: $data" + echo "Calling API: $description" + # Store response in a temporary file temp_file=$(mktemp) - http_code=$(curl -v -s -w "%{http_code}" \ + + # Execute curl with minimal output + response=$(curl -s \ --request "$method" "$url" \ --header "Authorization: Bearer ${{ steps.bytebase-login.outputs.token }}" \ --header "Content-Type: application/json" \ --data "$data" \ - -o "$temp_file" 2>&1) - - echo "=== DEBUG: Response Details ===" - echo "HTTP Status: $http_code" - echo "Response body:" - cat "$temp_file" - echo "===========================" + --write-out "\n%{http_code}" \ + 2>/dev/null) - if [[ $http_code -lt 200 || $http_code -ge 300 ]]; then - echo "Error: Failed $description. Status: $http_code" - cat "$temp_file" - rm "$temp_file" - return 1 - fi + http_code=$(echo "$response" | tail -n1) + body=$(echo "$response" | sed '$d') - if [[ ! -s "$temp_file" ]]; then - echo "Error: Empty response from server" - rm "$temp_file" - return 1 - fi + echo "Status code: $http_code" - # Simple one-line JSON validation - if ! python3 -c "import json,sys; json.load(open('$temp_file'))" 2>/dev/null; then - echo "Error: Invalid JSON response" - echo "Response content:" - cat "$temp_file" - rm "$temp_file" + if [[ $http_code -lt 200 || $http_code -ge 300 ]]; then + echo "Error: Failed $description" + echo "Response: $body" return 1 fi - cat "$temp_file" - rm "$temp_file" + echo "$body" return 0 } @@ -136,7 +118,8 @@ jobs: for file in ${{ steps.changed-files.outputs.all_changed_files }}; do echo "Processing $file" - 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 + 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 STEP_ID=$(python3 -c "import uuid; print(str(uuid.uuid4()))") echo "STEP_ID=$STEP_ID" >> $GITHUB_ENV BASE_URL="${{ steps.bytebase-login.outputs.api_url }}"