Skip to content

A branch 6 #31

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
61 changes: 52 additions & 9 deletions .github/workflows/bb-export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ jobs:
local data="$3"
local description="$4"

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

response=$(curl -s -w "\n%{http_code}" \
--request "$method" "$url" \
--header "Authorization: Bearer ${{ steps.bytebase-login.outputs.token }}" \
Expand All @@ -60,10 +66,20 @@ jobs:
status_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')

echo "=== DEBUG: Parsed Response ==="
echo "Status code: $status_code"
echo "Body length: ${#body}"
echo "Body content:"
echo "$body"
echo "==========================="

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

if [[ -z "$body" ]]; then
echo "Error: Empty response body"
return 1
fi

Expand All @@ -78,7 +94,7 @@ jobs:
while [[ "$DIR_PATH" == export* ]]; do
if [[ -f "$DIR_PATH/manifest.toml" ]]; then
MANIFEST_PATH="$DIR_PATH/manifest.toml"
break 2 # Break out of both loops once found
break 2
fi
DIR_PATH=$(dirname "$DIR_PATH")
done
Expand All @@ -89,11 +105,38 @@ jobs:
exit 1
fi

# Parse manifest.toml once using built-in tomllib
PROJECT=$(python3 -c "import tomllib; print(tomllib.load(open('$MANIFEST_PATH', 'rb'))['project'])")
INSTANCE=$(python3 -c "import tomllib; print(tomllib.load(open('$MANIFEST_PATH', 'rb'))['instance'])")
DATABASE=$(python3 -c "import tomllib; print(tomllib.load(open('$MANIFEST_PATH', 'rb'))['database'])")
FORMAT=$(python3 -c "import tomllib; config=tomllib.load(open('$MANIFEST_PATH', 'rb')); print(config.get('format', 'JSON'))")
echo "Found manifest file at: $MANIFEST_PATH"
echo "Manifest contents:"
cat "$MANIFEST_PATH"

# Parse manifest.toml with error handling
read_toml() {
local key="$1"
python3 -c "
import sys
import tomllib
try:
with open('$MANIFEST_PATH', 'rb') as f:
data = tomllib.load(f)
print(data.get('$key', ''))
except Exception as e:
print(f'Error reading $key: {str(e)}', file=sys.stderr)
sys.exit(1)
"
}

# Read each value with error handling
PROJECT=$(read_toml "project") || exit 1
INSTANCE=$(read_toml "instance") || exit 1
DATABASE=$(read_toml "database") || exit 1
FORMAT=$(read_toml "format") || FORMAT="JSON"

echo "=== Parsed Configuration ==="
echo "Project: $PROJECT"
echo "Instance: $INSTANCE"
echo "Database: $DATABASE"
echo "Format: $FORMAT"
echo "==========================="

# Process each SQL file
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
Expand Down
Loading