fix: support multiple package managers for sshpass installation
All checks were successful
site-dist-deploy / build-and-deploy (push) Successful in 1m33s

This commit is contained in:
shanshanzhong 2026-01-04 04:12:38 -08:00
parent 517d07caaf
commit e15366d5f7

View File

@ -74,7 +74,25 @@ jobs:
- name: Deploy to Host (Native SSH/SCP)
run: |
echo "Installing SSH tools..."
apt-get update -y && apt-get install -y sshpass openssh-client
if command -v apk &> /dev/null; then
echo "Detected Alpine Linux. Installing sshpass openssh-client via apk..."
apk add --no-cache sshpass openssh-client
elif command -v apt-get &> /dev/null; then
echo "Detected Debian/Ubuntu. Installing sshpass openssh-client via apt..."
apt-get update -y && apt-get install -y sshpass openssh-client
elif command -v yum &> /dev/null; then
echo "Detected RHEL/CentOS. Installing sshpass openssh-clients via yum..."
yum install -y sshpass openssh-clients
elif command -v dnf &> /dev/null; then
echo "Detected Fedora/RHEL8+. Installing sshpass openssh-clients via dnf..."
dnf install -y sshpass openssh-clients
elif command -v zypper &> /dev/null; then
echo "Detected OpenSUSE. Installing sshpass openssh via zypper..."
zypper install -y sshpass openssh
else
echo "Error: No known package manager found. Cannot install sshpass."
exit 1
fi
echo "Uploading artifact..."
# 使用 sshpass 传递密码 (更安全的方式是使用 key但此处沿用 password)