ci(docker): 修复构建时的GPG签名和时间同步问题
Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 26s

- 同步系统时间以解决GPG签名时间问题
- 配置HTTPS软件源避免HTTP连接的GPG问题
- 清理并重新安装GPG密钥确保包管理正常
This commit is contained in:
shanshanzhong 2025-10-13 18:20:08 -07:00
parent be74a1bd0f
commit 7a322b0534

View File

@ -68,6 +68,21 @@ jobs:
run: |
set -e
export DEBIAN_FRONTEND=noninteractive
# 1. 同步系统时间 (修复GPG签名时间问题)
echo "同步系统时间..."
if command -v ntpdate >/dev/null 2>&1; then
ntpdate -s time.nist.gov || true
elif command -v timedatectl >/dev/null 2>&1; then
timedatectl set-ntp true || true
fi
date
# 2. 配置HTTPS源 (避免HTTP连接的GPG问题)
echo "配置HTTPS软件源..."
sed -i 's|http://deb.debian.org|https://deb.debian.org|g' /etc/apt/sources.list
sed -i 's|http://security.debian.org|https://deb.debian.org|g' /etc/apt/sources.list
echo "等待 apt/dpkg 锁释放 (unattended-upgrades)..."
# 等待最多 300 秒让 unattended-upgrades/apt/dpkg 锁释放
end=$((SECONDS+300))
@ -92,7 +107,14 @@ jobs:
fi
echo "仍在等待锁释放..."; sleep 5
done
apt-get update -y -o Dpkg::Lock::Timeout=600
# 3. 清理并重新安装GPG密钥
echo "修复GPG密钥..."
rm -rf /var/lib/apt/lists/*
apt-get clean
apt-get update -y -o Dpkg::Lock::Timeout=600 -o Acquire::Retries=3
# 4. 安装软件包
apt-get install -y -o Dpkg::Lock::Timeout=600 jq curl ca-certificates docker.io
docker --version
jq --version