allow retry on connection loss

This commit is contained in:
Bryan Gerlach
2026-01-13 13:15:44 -06:00
parent 27b52d80e9
commit f9901f2f74
3 changed files with 69 additions and 34 deletions

View File

@@ -87,23 +87,35 @@ jobs:
import io import io
import os import os
import json import json
import time
r = requests.get('${{ fromJson(inputs.zip_url).url }}/get_zip?filename=${{ fromJson(inputs.zip_url).file }}') for attempt in range(5):
r.raise_for_status() try:
print(f"Downloading secrets (Attempt {attempt + 1})...")
r = requests.get('${{ fromJson(inputs.zip_url).url }}/get_zip?filename=${{ fromJson(inputs.zip_url).file }}', timeout=60)
r.raise_for_status()
break
except (requests.exceptions.RequestException, requests.exceptions.Timeout) as e:
if attempt < 4:
print(f"Timeout/Error occurred: {e}. Retrying in 5 seconds...")
time.sleep(5)
else:
print("Max retries reached. Failing.")
raise e
try: try:
with pyzipper.AESZipFile(io.BytesIO(r.content)) as zf: with pyzipper.AESZipFile(io.BytesIO(r.content)) as zf:
zf.setpassword('${{ secrets.ZIP_PASSWORD }}'.encode()) zf.setpassword('${{ secrets.ZIP_PASSWORD }}'.encode())
with zf.open('secrets.json') as f: with zf.open('secrets.json') as f:
secrets = json.load(f) secrets = json.load(f)
except Exception as e: except Exception as e:
print(f"Error: Could not decrypt ZIP. Check if password matches. {e}") print(f"Error: Could not decrypt ZIP. Check if password matches. {e}")
exit(1) exit(1)
with open(os.environ['GITHUB_ENV'], 'a') as env_file: with open(os.environ['GITHUB_ENV'], 'a') as env_file:
for key, value in secrets.items(): for key, value in secrets.items():
print(f"::add-mask::{value}") print(f"::add-mask::{value}")
env_file.write(f"{key}={value}\n") env_file.write(f"{key}={value}\n")
print("Secrets loaded into environment.") print("Secrets loaded into environment.")

View File

@@ -3,7 +3,6 @@ run-name: Custom Windows x86 Client Generator
on: on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
inputs:
version: version:
description: 'version to buld' description: 'version to buld'
required: true required: true
@@ -77,23 +76,35 @@ jobs:
import io import io
import os import os
import json import json
import time
r = requests.get('${{ fromJson(inputs.zip_url).url }}/get_zip?filename=${{ fromJson(inputs.zip_url).file }}') for attempt in range(5):
r.raise_for_status() try:
print(f"Downloading secrets (Attempt {attempt + 1})...")
r = requests.get('${{ fromJson(inputs.zip_url).url }}/get_zip?filename=${{ fromJson(inputs.zip_url).file }}', timeout=60)
r.raise_for_status()
break
except (requests.exceptions.RequestException, requests.exceptions.Timeout) as e:
if attempt < 4:
print(f"Timeout/Error occurred: {e}. Retrying in 5 seconds...")
time.sleep(5)
else:
print("Max retries reached. Failing.")
raise e
try: try:
with pyzipper.AESZipFile(io.BytesIO(r.content)) as zf: with pyzipper.AESZipFile(io.BytesIO(r.content)) as zf:
zf.setpassword('${{ secrets.ZIP_PASSWORD }}'.encode()) zf.setpassword('${{ secrets.ZIP_PASSWORD }}'.encode())
with zf.open('secrets.json') as f: with zf.open('secrets.json') as f:
secrets = json.load(f) secrets = json.load(f)
except Exception as e: except Exception as e:
print(f"Error: Could not decrypt ZIP. Check if password matches. {e}") print(f"Error: Could not decrypt ZIP. Check if password matches. {e}")
exit(1) exit(1)
with open(os.environ['GITHUB_ENV'], 'a') as env_file: with open(os.environ['GITHUB_ENV'], 'a') as env_file:
for key, value in secrets.items(): for key, value in secrets.items():
print(f"::add-mask::{value}") print(f"::add-mask::{value}")
env_file.write(f"{key}={value}\n") env_file.write(f"{key}={value}\n")
print("Secrets loaded into environment.") print("Secrets loaded into environment.")

View File

@@ -87,23 +87,35 @@ jobs:
import io import io
import os import os
import json import json
import time
r = requests.get('${{ fromJson(inputs.zip_url).url }}/get_zip?filename=${{ fromJson(inputs.zip_url).file }}') for attempt in range(5):
r.raise_for_status() try:
print(f"Downloading secrets (Attempt {attempt + 1})...")
r = requests.get('${{ fromJson(inputs.zip_url).url }}/get_zip?filename=${{ fromJson(inputs.zip_url).file }}', timeout=60)
r.raise_for_status()
break
except (requests.exceptions.RequestException, requests.exceptions.Timeout) as e:
if attempt < 4:
print(f"Timeout/Error occurred: {e}. Retrying in 5 seconds...")
time.sleep(5)
else:
print("Max retries reached. Failing.")
raise e
try: try:
with pyzipper.AESZipFile(io.BytesIO(r.content)) as zf: with pyzipper.AESZipFile(io.BytesIO(r.content)) as zf:
zf.setpassword('${{ secrets.ZIP_PASSWORD }}'.encode()) zf.setpassword('${{ secrets.ZIP_PASSWORD }}'.encode())
with zf.open('secrets.json') as f: with zf.open('secrets.json') as f:
secrets = json.load(f) secrets = json.load(f)
except Exception as e: except Exception as e:
print(f"Error: Could not decrypt ZIP. Check if password matches. {e}") print(f"Error: Could not decrypt ZIP. Check if password matches. {e}")
exit(1) exit(1)
with open(os.environ['GITHUB_ENV'], 'a') as env_file: with open(os.environ['GITHUB_ENV'], 'a') as env_file:
for key, value in secrets.items(): for key, value in secrets.items():
print(f"::add-mask::{value}") print(f"::add-mask::{value}")
env_file.write(f"{key}={value}\n") env_file.write(f"{key}={value}\n")
print("Secrets loaded into environment.") print("Secrets loaded into environment.")