fix(ci): checkout without git in slim runner image
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 19m35s

This commit is contained in:
Xiaoxia AI
2026-06-20 19:03:52 +08:00
parent 8df0a476c0
commit 32d6d0eb9d
2 changed files with 49 additions and 5 deletions
+25 -3
View File
@@ -18,13 +18,35 @@ jobs:
validate:
name: Validate Code Quality And Tests
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest
container: python:3.12-slim
steps:
- name: Checkout code
run: |
git clone --depth=1 --branch=${GITHUB_REF_NAME} https://api.xiaoxiajianji.com/git/${GITHUB_REPOSITORY}.git .
git checkout ${GITHUB_SHA}
python - <<'PY'
import os
import tarfile
import urllib.request
api_url = os.environ['GITHUB_API_URL']
repository = os.environ['GITHUB_REPOSITORY']
sha = os.environ['GITHUB_SHA']
token = os.environ.get('GITHUB_TOKEN', '')
archive_url = f"{api_url}/repos/{repository}/archive/{sha}.tar.gz"
request = urllib.request.Request(archive_url)
if token:
request.add_header('Authorization', f'token {token}')
with urllib.request.urlopen(request, timeout=120) as response:
with open('/tmp/repo.tar.gz', 'wb') as archive:
archive.write(response.read())
with tarfile.open('/tmp/repo.tar.gz', 'r:gz') as archive:
members = archive.getmembers()
top_level = members[0].name.split('/')[0] + '/'
for member in members:
member.name = member.name.removeprefix(top_level)
if member.name:
archive.extract(member, '.')
PY
- name: Prepare environment
run: |