Skip to content

put back temp file #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 34 additions & 15 deletions .github/workflows/bb-export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,50 @@ jobs:
local data="$3"
local description="$4"

echo "Calling API: $description"
echo "=== DEBUG: API Call Details ==="
echo "Description: $description"
echo "URL: $url"
echo "Method: $method"
echo "Data: $data"

# Store response in a temporary file
temp_file=$(mktemp)

# Execute curl with minimal output
response=$(curl -s \
http_code=$(curl -v -s -w "%{http_code}" \
--request "$method" "$url" \
--header "Authorization: Bearer ${{ steps.bytebase-login.outputs.token }}" \
--header "Content-Type: application/json" \
--data "$data" \
--write-out "\n%{http_code}" \
2>/dev/null)

http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
-o "$temp_file" 2>&1)

echo "Status code: $http_code"
echo "=== DEBUG: Response Details ==="
echo "HTTP Status: $http_code"
echo "Response body:"
cat "$temp_file"
echo "==========================="

if [[ $http_code -lt 200 || $http_code -ge 300 ]]; then
echo "Error: Failed $description"
echo "Response: $body"
echo "Error: Failed $description. Status: $http_code"
cat "$temp_file"
rm "$temp_file"
return 1
fi

if [[ ! -s "$temp_file" ]]; then
echo "Error: Empty response from server"
rm "$temp_file"
return 1
fi

# 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"
return 1
fi

cat "$temp_file"
rm "$temp_file"
return 0
}

Expand Down Expand Up @@ -117,12 +136,12 @@ 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])")
SQL_CONTENT=$(base64 < "$file")
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 }}"
echo "BASE_URL111=$BASE_URL"
echo "BASE_URL1111=$BASE_URL"
echo "BASE_URL=$BASE_URL" >> $GITHUB_ENV

sheet_data=$(call_api \
Expand Down
Loading