From ceed0636dae9044f438dcf316662c97c5bbd422c Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 13 Jul 2026 21:00:58 +0800 Subject: [PATCH] chore: add CI image build workflow --- .gitea/workflows/build-ci-image.yml | 63 +++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .gitea/workflows/build-ci-image.yml diff --git a/.gitea/workflows/build-ci-image.yml b/.gitea/workflows/build-ci-image.yml new file mode 100644 index 000000000..b48805ed6 --- /dev/null +++ b/.gitea/workflows/build-ci-image.yml @@ -0,0 +1,63 @@ +name: Build CI Docker Image + +on: + workflow_dispatch: + push: + branches: + - ops/downgrade-runners + paths: + - 'infra/docker/ci.Dockerfile' + - 'requirements*.txt' + - '.gitea/workflows/build-ci-image.yml' + +jobs: + build-ci-image: + runs-on: runtime-builder + steps: + - name: Checkout code + shell: sh + run: | + set -eu + python3 - <<'PY' + import io, os, tarfile, urllib.request + 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']}"}) + with urllib.request.urlopen(request, timeout=120) as response: + archive = response.read() + 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 + + - name: Build CI image + shell: sh + run: | + set -eu + cd infra/docker + docker build -f ci.Dockerfile -t localhost:5000/xiaoxia-ci-python:3.12 ../.. + + - name: Push CI image to local registry + shell: sh + run: | + set -eu + docker push localhost:5000/xiaoxia-ci-python:3.12 + + - name: Verify image in registry + shell: sh + run: | + set -eu + echo "=== Docker images ===" + docker images | grep xiaoxia-ci-python || echo "no local image found" + echo "" + echo "=== Registry catalog (via docker) ===" + docker search localhost:5000/xiaoxia-ci-python || echo "search failed" + echo "" + echo "=== Image tags ===" + curl -s http://localhost:5000/v2/xiaoxia-ci-python/tags/list || echo "curl failed"