fix(ci): code-review换回actions/checkout@v3(runner层处理不受容器网络影响)
AI Code Review / AI Code Review (pull_request) Successful in 2m25s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m29s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 7m39s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 10m4s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 10m4s
Preview Cleanup / Cleanup Preview Environment (pull_request) Failing after 1s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 1393h52m57s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1393h55m9s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1393h55m11s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1393h55m11s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 1393h55m13s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 1393h55m13s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1393h55m13s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 1393h55m17s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 1393h55m17s
CI/CD Pipeline / Check if frontend-only change (pull_request) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 1394h27m19s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1394h27m19s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 1394h27m21s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 1394h27m25s
AI Code Review / AI Code Review (pull_request) Successful in 2m25s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m29s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 7m39s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 10m4s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 10m4s
Preview Cleanup / Cleanup Preview Environment (pull_request) Failing after 1s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 1393h52m57s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1393h55m9s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1393h55m11s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1393h55m11s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 1393h55m13s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 1393h55m13s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1393h55m13s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 1393h55m17s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 1393h55m17s
CI/CD Pipeline / Check if frontend-only change (pull_request) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 1394h27m19s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1394h27m19s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 1394h27m21s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 1394h27m25s
This commit is contained in:
@@ -20,56 +20,11 @@ jobs:
|
||||
if: ${{ !gitea.event.pull_request.draft }}
|
||||
|
||||
steps:
|
||||
# actions/checkout 由 runner 在宿主机层面处理,不受容器网络影响
|
||||
- name: Checkout code
|
||||
shell: sh
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||
run: |
|
||||
set -eu
|
||||
python3 - <<'PY'
|
||||
import io, os, tarfile, time, urllib.request, urllib.error
|
||||
# 用 gitea.server_url(公网地址)替代 GITHUB_API_URL(容器内可能不可达)
|
||||
server_url = os.environ.get('GITEA_SERVER_URL', '').rstrip('/')
|
||||
repo = os.environ['GITHUB_REPOSITORY']
|
||||
sha = os.environ['GITHUB_SHA']
|
||||
url = f"{server_url}/api/v1/repos/{repo}/archive/{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
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user