Skip to content

Commit

Permalink
ci: Fix artifact upload logic
Browse files Browse the repository at this point in the history
Curl doesn't exit with non-zero code on bad HTTP responses unless you
include the `--fail-with-body` option. This should allow our retry logic
to actually work.

This also changed from `-v` which is too verbose to options that will
print response headers and the HTTP status code. A new failure example
will look like:
```
h /tmp/tmp.sh
HTTP/2 404
content-type: text/plain; charset=utf-8
x-content-type-options: nosniff
x-correlation-id: olpibb8dckt9en06
x-cloud-trace-context: b7bce595271f58d4f9ba5110b79664a7;o=1
date: Wed, 04 Dec 2024 16:05:47 GMT
server: Google Frontend
content-length: 15
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

Does not exist
curl: (22) The requested URL returned error: 404
404
Error: unable to publish artifacts, sleep and retry
HTTP/2 404
content-type: text/plain; charset=utf-8
x-content-type-options: nosniff
x-correlation-id: ksbj4bkxr0e4ccor
x-cloud-trace-context: 211fe02ffdb72279d1236715f01fc2b8
date: Wed, 04 Dec 2024 16:05:50 GMT
server: Google Frontend
content-length: 15
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

Does not exist
curl: (22) The requested URL returned error: 404
404
Error: unable to publish artifacts, sleep and retry
HTTP/2 404
content-type: text/plain; charset=utf-8
x-content-type-options: nosniff
x-correlation-id: mv9svphecr7a5d40
x-cloud-trace-context: 4c284a6b61832b999b5fb7097596324c
date: Wed, 04 Dec 2024 16:05:52 GMT
server: Google Frontend
content-length: 15
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

Does not exist
curl: (22) The requested URL returned error: 404
404
Error: unable to publish artifacts, sleep and retry
Failed to publish artifacts
```

Signed-off-by: Andy Doan <[email protected]>
  • Loading branch information
doanac authored and ricardosalveti committed Dec 4, 2024
1 parent 18ce0b2 commit 9731612
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build-yocto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ jobs:
retries=3
for ((i=0; i<retries; i++)); do
curl -X POST -v ${url} && break
echo "something went wrong, sleep and retry"
curl -X POST -i -w '%{http_code}' --fail-with-body ${url} && break
echo # new line break in case response doesn't have one
echo "Error: unable to publish artifacts, sleep and retry"
sleep 2
done
(( retries == i )) && { echo 'Failed to publish artifacts'; exit 1; }
echo # new line break in case response doesn't have one
echo Image available at: ${url}

0 comments on commit 9731612

Please sign in to comment.