0a8bfc9bcc
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Failing after 24s
CI/CD Pipeline / Build Staging Web Image (push) Failing after 29s
CI/CD Pipeline / Build Staging Worker Image (push) Failing after 29s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (push) Has been skipped
CI/CD Pipeline / Staging E2E Tests (push) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (push) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 3m23s
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 3m24s
CI/CD Pipeline / Frontend Lint (push) Successful in 3m49s
CI/CD Pipeline / Unit Tests (push) Successful in 4m7s
CI/CD Pipeline / Integration Tests (push) Successful in 1m32s
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
45 lines
1.6 KiB
Bash
Executable File
45 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# CI 公共步骤:Checkout 代码(带重试)
|
|
# 用法:直接 source 或调用,需要 GITHUB_TOKEN 环境变量
|
|
set -eu
|
|
|
|
python3 - <<'PY'
|
|
import io, os, tarfile, time, urllib.request, urllib.error
|
|
url = f"{os.environ['GITHUB_API_URL']}/repos/{os.environ['GITHUB_REPOSITORY']}/archive/{os.environ['GITHUB_SHA']}.tar.gz"
|
|
request = urllib.request.Request(url, headers={"Authorization": f"token {os.environ['GITHUB_TOKEN']}"})
|
|
last_err = None
|
|
for attempt in range(5):
|
|
try:
|
|
with urllib.request.urlopen(request, timeout=120) as response:
|
|
archive = response.read()
|
|
break
|
|
except urllib.error.HTTPError as e:
|
|
last_err = e
|
|
if e.code >= 500 and attempt < 4:
|
|
wait = 2 ** attempt
|
|
print(f"Checkout HTTP {e.code}, retrying in {wait}s (attempt {attempt+1}/5)...")
|
|
time.sleep(wait)
|
|
continue
|
|
raise
|
|
except Exception as e:
|
|
last_err = e
|
|
if attempt < 4:
|
|
wait = 2 ** attempt
|
|
print(f"Checkout error: {e}, retrying in {wait}s (attempt {attempt+1}/5)...")
|
|
time.sleep(wait)
|
|
continue
|
|
raise
|
|
else:
|
|
raise last_err
|
|
with tarfile.open(fileobj=io.BytesIO(archive), mode='r:gz') as tar:
|
|
root_prefix = tar.getmembers()[0].name.split('/', 1)[0] + '/'
|
|
for member in tar.getmembers():
|
|
name = member.name
|
|
if name == root_prefix[:-1]:
|
|
continue
|
|
if name.startswith(root_prefix):
|
|
member.name = name[len(root_prefix):]
|
|
if member.name:
|
|
tar.extract(member, '.')
|
|
PY
|