github actions: filter http codes when publishing changes, handle 504

Aptly may process request for long time enough to make CloudFlare or
server drop connection. Treat this as false failure and don't stop
GitHub Actions with error status.
This commit is contained in:
Leonid Pliushch 2021-12-05 12:00:46 +02:00
parent c37c34b468
commit 7aa03f39d8
No known key found for this signature in database
GPG Key ID: 45F2964132545795
1 changed files with 7 additions and 2 deletions

View File

@ -287,14 +287,19 @@ jobs:
--write-out '|%{http_code}' \
https://packages-cf.termux.org/aptly-api/publish/${REPOSITORY_NAME}/${REPOSITORY_DISTRIBUTION} || true
)
http_status_code=$(echo "$curl_response" | cut -d'|' -f2)
http_status_code=$(echo "$curl_response" | cut -d'|' -f2 | grep -oP '\d{3}$')
if [ "$http_status_code" = "200" ]; then
echo "[$(date +%H:%M:%S)] Repository has been updated successfully."
elif [ "$http_status_code" = "000" ]; then
echo "[$(date +%H:%M:%S)] Error: server/proxy has dropped connection."
echo "[$(date +%H:%M:%S)] Warning: server/proxy has dropped connection."
# Ignore - nothing can be done with that unless we change proxy.
#exit 1
elif [ "$http_status_code" = "504" ]; then
echo "[$(date +%H:%M:%S)] Warning: request processing time was too long, connection dropped."
# Ignore - nothing can be done with that unless we change repository
# management tool or reduce repository size.
#exit 1
else
echo "[$(date +%H:%M:%S)] Error: got http_status_code == '$http_status_code'"
exit 1