Skip to content

Commit ff9633d

Browse files
Raise Static Build After Waiting
Adds a missing raise in the static build for situations where everything was successful, but the build time passed the deadline specified by the site API. Signed-off-by: Hassan Abouelela <[email protected]>
1 parent 8ab501c commit ff9633d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

static-builds/netlify_build.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515

1616
import httpx
1717

18+
19+
def raise_response(response: httpx.Response) -> None:
20+
"""Raise an exception from a response if necessary."""
21+
if response.status_code // 100 != 2:
22+
try:
23+
print(response.json())
24+
except json.JSONDecodeError:
25+
pass
26+
27+
response.raise_for_status()
28+
29+
1830
if __name__ == "__main__":
1931
owner, repo = parse.urlparse(os.getenv("REPOSITORY_URL")).path.lstrip("/").split("/")[0:2]
2032

@@ -29,21 +41,15 @@
2941
])
3042
print(f"Fetching download URL from {download_url}")
3143
response = httpx.get(download_url, follow_redirects=True)
32-
33-
if response.status_code // 100 != 2:
34-
try:
35-
print(response.json())
36-
except json.JSONDecodeError:
37-
pass
38-
39-
response.raise_for_status()
44+
raise_response(response)
4045

4146
# The workflow is still pending, retry in a bit
4247
while response.status_code == 202:
4348
print(f"{response.json()['error']}. Retrying in 10 seconds.")
4449
time.sleep(10)
4550
response = httpx.get(download_url, follow_redirects=True)
4651

52+
raise_response(response)
4753
url = response.json()["url"]
4854
print(f"Downloading build from {url}")
4955
zipped_content = httpx.get(url, follow_redirects=True)

0 commit comments

Comments
 (0)