Skip to content

Commit 92ee52b

Browse files
committed
Retry grype download on failure
1 parent 4817a45 commit 92ee52b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

.github/workflows/ci.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import sys
1313
import tarfile
1414
import time
15+
from urllib.error import URLError
1516
from urllib.request import Request, urlopen
1617

1718
BUNDLE_URL = 'https://download.calibre-ebook.com/ci/kitty/{}-64.tar.xz'
@@ -187,8 +188,13 @@ def install_grype() -> str:
187188
rq = Request('https://api.github.com/repos/anchore/grype/releases/latest', headers={
188189
'Accept': 'application/vnd.github.v3+json',
189190
})
190-
with urlopen(rq) as f:
191-
m = json.loads(f.read())
191+
try:
192+
with urlopen(rq) as f:
193+
m = json.loads(f.read())
194+
except URLError:
195+
time.sleep(1)
196+
with urlopen(rq) as f:
197+
m = json.loads(f.read())
192198
for asset in m['assets']:
193199
if asset['name'].endswith('_linux_amd64.tar.gz'):
194200
url = asset['browser_download_url']

0 commit comments

Comments
 (0)