ci: 换 runner 内 Ubuntu apt 源到阿里云

上次跑到 apt-get update 60s 超时(timeout 兜底生效)。原因:
- Runner (ubuntu-latest) 用的是 archive.ubuntu.com / security.ubuntu.com
- 之前的 sed 只匹配 deb.debian.org,对 Ubuntu 源根本没换

修改:
- 换 Ubuntu 源到 mirrors.aliyun.com,兼容 legacy /etc/apt/sources.list、
  deb822 .sources 和 sources.list.d/*.list 三种格式
- update timeout 60s → 90s,install 180s → 240s,给国内源一点余量

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
yuming
2026-07-04 14:28:12 +08:00
parent 1899f90b5c
commit 9038c39afa
+8 -4
View File
@@ -10,14 +10,18 @@ jobs:
steps: steps:
- name: 安装 Docker CLI - name: 安装 Docker CLI
run: | run: |
# 大概率 gitea act_runner 已预装 docker,先探测(避免 apt 走国外源 3h 超时) # 大概率 gitea act_runner 已预装 docker,先探测(避免 apt 走国外源超时)
if command -v docker >/dev/null 2>&1; then if command -v docker >/dev/null 2>&1; then
echo "Docker 已预装:$(docker --version)" echo "Docker 已预装:$(docker --version)"
exit 0 exit 0
fi fi
echo "Docker 未预装,开始 apt 安装(每步限时 3 分钟,超时快速失败)" echo "Docker 未预装,换 Ubuntu 源到阿里云再 apt 安装"
timeout 60 apt-get update -qq || { echo "apt-get update 超时/失败"; exit 1; } # 兼容 legacy sources.list、deb822 .sources、以及 sources.list.d/*.list
timeout 180 apt-get install -y -qq docker.io || { echo "docker.io 安装超时/失败"; exit 1; } sed -i 's|archive.ubuntu.com|mirrors.aliyun.com|g;s|security.ubuntu.com|mirrors.aliyun.com|g' /etc/apt/sources.list 2>/dev/null || true
sed -i 's|archive.ubuntu.com|mirrors.aliyun.com|g;s|security.ubuntu.com|mirrors.aliyun.com|g' /etc/apt/sources.list.d/*.sources 2>/dev/null || true
sed -i 's|archive.ubuntu.com|mirrors.aliyun.com|g;s|security.ubuntu.com|mirrors.aliyun.com|g' /etc/apt/sources.list.d/*.list 2>/dev/null || true
timeout 90 apt-get update -qq || { echo "apt-get update 超时/失败"; exit 1; }
timeout 240 apt-get install -y -qq docker.io || { echo "docker.io 安装超时/失败"; exit 1; }
docker --version docker --version
- name: 拉取代码 - name: 拉取代码