Fix HTTP code extraction using curl -w flag for reliable status code detection
Some checks failed
Build libostree Backport / Build libostree Backport (push) Failing after 9m46s

This commit is contained in:
robojerk 2025-07-21 20:04:57 +00:00
parent 2dd88a7b89
commit 359713ef5d

View file

@ -281,9 +281,9 @@ jobs:
# Check if ACCESS_TOKEN is available (without exposing the actual token)
echo "=== Checking ACCESS_TOKEN ==="
if [ -n "${{ secrets.ACCESS_TOKEN }}" ]; then
echo "ACCESS_TOKEN is set (length: ${#ACCESS_TOKEN} characters)"
echo "secrets.ACCESS_TOKEN is populated. First 4 chars: ${{ secrets.ACCESS_TOKEN | slice(0, 4) }}"
else
echo "❌ ACCESS_TOKEN is not set or empty"
echo "❌ secrets.ACCESS_TOKEN is EMPTY or NOT SET. THIS IS A CRITICAL ERROR."
exit 1
fi
echo "=== End token check ==="
@ -295,30 +295,24 @@ jobs:
echo "File: $filename"
# Capture full response (headers + body) to parse HTTP code AND package ID
# Add -v for verbose output and redirect stderr to see connection details
response_and_code=$(curl -v -i --user "robojerk:${{ secrets.ACCESS_TOKEN }}" \
--upload-file "$deb_file" \
"https://git.raines.xyz/api/packages/robojerk/debian/pool/noble/main/upload" 2>&1)
echo "=== Full curl output for $deb_file ==="
echo "$response_and_code"
echo "=== End curl output ==="
# Extract HTTP code from verbose output (look for the actual HTTP response line)
http_code=$(echo "$response_and_code" | grep -oP '^< HTTP/\d.\d \K\d{3}' | tail -1 || echo "N/A")
# Extract JSON body (after headers) - but 201 responses typically have no body
response_body=$(echo "$response_and_code" | awk '/^\r?$/{p=1;next}p')
# First, get only the HTTP code using curl's -w flag for reliable extraction
http_code=$(curl -s -o /dev/null -w "%{http_code}" \
--user "robojerk:${{ secrets.ACCESS_TOKEN }}" \
--upload-file "$deb_file" \
"https://git.raines.xyz/api/packages/robojerk/debian/pool/noble/main/upload")
echo "HTTP Response Code: $http_code"
if [ "$http_code" = "201" ]; then
echo "✅ Debian Package Registry upload SUCCESS for $deb_file"
# Note: 201 responses typically have no body, so no package ID to extract
# We'll need to find the package ID later by listing packages
echo "Package uploaded successfully (no ID returned in response)"
else
echo "❌ Debian Package Registry upload FAILED for $deb_file (HTTP $http_code)"
echo "Response body: $response_body"
echo "Printing full verbose curl output for debugging failure:"
# If it failed, print the verbose output for debugging
curl -v -i --user "robojerk:${{ secrets.ACCESS_TOKEN }}" \
--upload-file "$deb_file" \
"https://git.raines.xyz/api/packages/robojerk/debian/pool/noble/main/upload" 2>&1
exit 1 # Fail the step if upload fails
fi
fi