From 093275bc80cbd7c9cf4847228ccde6993356700c Mon Sep 17 00:00:00 2001 From: UUBulb <35923940+uubulb@users.noreply.github.com> Date: Sun, 18 Aug 2024 08:56:32 +0800 Subject: [PATCH] =?UTF-8?q?ci=E5=A2=9E=E5=8A=A0=E9=87=8D=E4=BC=A0=E6=9C=BA?= =?UTF-8?q?=E5=88=B6=20(#54)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sync.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/sync.py b/.github/workflows/sync.py index 2bac303..1ac28a2 100644 --- a/.github/workflows/sync.py +++ b/.github/workflows/sync.py @@ -110,20 +110,24 @@ def sync_to_gitee(tag: str, body: str, files: slice): asset_api_uri = f"{release_api_uri}/{release_id}/attach_files" for file_path in files: - files = { - 'file': open(file_path, 'rb') - } + success = False - asset_api_response = requests.post( - asset_api_uri, params={'access_token': access_token}, files=files) + while not success: + files = { + 'file': open(file_path, 'rb') + } - if asset_api_response.status_code == 201: - asset_info = asset_api_response.json() - asset_name = asset_info.get('name') - print(f"Successfully uploaded {asset_name}!") - else: - print( - f"Request failed with status code {asset_api_response.status_code}") + asset_api_response = requests.post( + asset_api_uri, params={'access_token': access_token}, files=files) + + if asset_api_response.status_code == 201: + asset_info = asset_api_response.json() + asset_name = asset_info.get('name') + print(f"Successfully uploaded {asset_name}!") + success = True + else: + print( + f"Request failed with status code {asset_api_response.status_code}") # 仅保留最新 Release 以防超出 Gitee 仓库配额 try: