From 11c85da65d5bbdca47af16a38b7ce797a6d7d569 Mon Sep 17 00:00:00 2001 From: Blizzard Date: Sat, 25 Jul 2026 17:22:05 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E5=8A=A0=E9=80=9F=20ssh=20=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E5=AE=89=E8=A3=85=EF=BC=88=E5=B7=B2=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E5=88=99=E8=B7=B3=E8=BF=87=20+=20=E9=98=BF=E9=87=8C=E4=BA=91?= =?UTF-8?q?=E6=BA=90=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gitea Actions 每个 job 都在全新容器执行,装过的包不会保留,只能 每次重装。原来 apt-get update 连境外源经常拖到几分钟,改为: 先检测 sshpass/ssh 是否已存在(部分 runner 镜像自带,命中即 0 秒), 否则把 apt/apk 源换成 mirrors.aliyun.com 再装。 Co-Authored-By: Claude Opus 4.8 --- .gitea/workflows/deploy.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index b93d9cc..74be0b8 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -34,12 +34,26 @@ jobs: - name: 导出镜像为压缩包 run: docker save "$IMAGE" | gzip > image.tar.gz + # 每次 job 都是全新容器,装过的东西不会留下。这里做两件事提速: + # 1) 已经有就直接跳过;2) 换阿里云镜像源,避免连境外源拖到几分钟。 - name: 安装 ssh 工具 run: | - if command -v apt-get >/dev/null; then - apt-get update && apt-get install -y sshpass openssh-client - elif command -v apk >/dev/null; then + if command -v sshpass >/dev/null && command -v ssh >/dev/null; then + echo "sshpass/ssh 已存在,跳过安装"; exit 0 + fi + if command -v apk >/dev/null; then + sed -i 's#dl-cdn.alpinelinux.org#mirrors.aliyun.com#g' /etc/apk/repositories apk add --no-cache sshpass openssh-client + elif command -v apt-get >/dev/null; then + sed -i -e 's#deb.debian.org#mirrors.aliyun.com#g' \ + -e 's#security.debian.org#mirrors.aliyun.com#g' \ + -e 's#archive.ubuntu.com#mirrors.aliyun.com#g' \ + -e 's#security.ubuntu.com#mirrors.aliyun.com#g' \ + /etc/apt/sources.list 2>/dev/null || true + sed -i -e 's#deb.debian.org#mirrors.aliyun.com#g' \ + -e 's#archive.ubuntu.com#mirrors.aliyun.com#g' \ + /etc/apt/sources.list.d/*.sources /etc/apt/sources.list.d/*.list 2>/dev/null || true + apt-get update -qq && apt-get install -y -qq --no-install-recommends sshpass openssh-client fi - name: 传镜像包与 compose 到服务器