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
Some checks failed
Build libostree Backport / Build libostree Backport (push) Failing after 9m46s
This commit is contained in:
parent
2dd88a7b89
commit
359713ef5d
1 changed files with 12 additions and 18 deletions
|
|
@ -281,9 +281,9 @@ jobs:
|
||||||
# Check if ACCESS_TOKEN is available (without exposing the actual token)
|
# Check if ACCESS_TOKEN is available (without exposing the actual token)
|
||||||
echo "=== Checking ACCESS_TOKEN ==="
|
echo "=== Checking ACCESS_TOKEN ==="
|
||||||
if [ -n "${{ secrets.ACCESS_TOKEN }}" ]; then
|
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
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "=== End token check ==="
|
echo "=== End token check ==="
|
||||||
|
|
@ -295,30 +295,24 @@ jobs:
|
||||||
echo "File: $filename"
|
echo "File: $filename"
|
||||||
|
|
||||||
# Capture full response (headers + body) to parse HTTP code AND package ID
|
# Capture full response (headers + body) to parse HTTP code AND package ID
|
||||||
# Add -v for verbose output and redirect stderr to see connection details
|
# First, get only the HTTP code using curl's -w flag for reliable extraction
|
||||||
response_and_code=$(curl -v -i --user "robojerk:${{ secrets.ACCESS_TOKEN }}" \
|
http_code=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
|
--user "robojerk:${{ secrets.ACCESS_TOKEN }}" \
|
||||||
--upload-file "$deb_file" \
|
--upload-file "$deb_file" \
|
||||||
"https://git.raines.xyz/api/packages/robojerk/debian/pool/noble/main/upload" 2>&1)
|
"https://git.raines.xyz/api/packages/robojerk/debian/pool/noble/main/upload")
|
||||||
|
|
||||||
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')
|
|
||||||
|
|
||||||
echo "HTTP Response Code: $http_code"
|
echo "HTTP Response Code: $http_code"
|
||||||
|
|
||||||
if [ "$http_code" = "201" ]; then
|
if [ "$http_code" = "201" ]; then
|
||||||
echo "✅ Debian Package Registry upload SUCCESS for $deb_file"
|
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)"
|
echo "Package uploaded successfully (no ID returned in response)"
|
||||||
else
|
else
|
||||||
echo "❌ Debian Package Registry upload FAILED for $deb_file (HTTP $http_code)"
|
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
|
exit 1 # Fail the step if upload fails
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue