aboutsummaryrefslogtreecommitdiffstats
path: root/static-builds
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-07-12 14:45:22 +0400
committerGravatar Hassan Abouelela <[email protected]>2022-07-12 14:55:15 +0400
commit26a3c19b53883015e8ba87db2a668c3eece2ce20 (patch)
tree0bf82c6eeea2c8f248253f559ef29547db64d620 /static-builds
parentUpdate Netlify Build Script (diff)
Make Awaiting Workflow Run A User Responsibility
Moves the responsibility of re-requesting a workflow run from the API to the user. This makes the requests much shorter-lived, and allows the client to control how they want to handle sleeping and retrying. This also has the benefit of removing the only real piece of async code, so now the view is completely sync once again. Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'static-builds')
-rw-r--r--static-builds/netlify_build.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/static-builds/netlify_build.py b/static-builds/netlify_build.py
index 13cd0279..a473bd91 100644
--- a/static-builds/netlify_build.py
+++ b/static-builds/netlify_build.py
@@ -8,6 +8,7 @@
import json
import os
+import time
import zipfile
from pathlib import Path
from urllib import parse
@@ -29,7 +30,7 @@ if __name__ == "__main__":
print(f"Fetching download URL from {download_url}")
response = httpx.get(download_url, follow_redirects=True)
- if response.status_code != 200:
+ if response.status_code // 100 != 2:
try:
print(response.json())
except json.JSONDecodeError:
@@ -37,6 +38,12 @@ if __name__ == "__main__":
response.raise_for_status()
+ # The workflow is still pending, retry in a bit
+ while response.status_code == 202:
+ print(f"{response.json()['error']}. Retrying in 10 seconds.")
+ time.sleep(10)
+ response = httpx.get(download_url, follow_redirects=True)
+
url = response.json()["url"]
print(f"Downloading build from {url}")
zipped_content = httpx.get(url, follow_redirects=True)