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 到服务器