feat: check for SSH, attempt install via package manager if missing
Some checks failed
Deploy Example / Deploy using ssh-remote shell (push) Has been cancelled
Deploy Example / Deploy using direct SSH (push) Has been cancelled

This commit is contained in:
Karolis2011 2025-11-19 23:21:20 +02:00
parent a5027e414c
commit c54d7dfa89

View file

@ -57,6 +57,46 @@ runs:
# Create SSH directory
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# Ensure ssh client is present. If not, try to install using a known
# package manager (apt, yum/dnf, apk, brew, pkg). If installation
# fails, stop early with helpful message.
if ! command -v ssh >/dev/null 2>&1; then
echo "SSH client 'ssh' not found. Attempting to install..."
if command -v apt-get >/dev/null 2>&1; then
echo "Using apt-get to install openssh-client"
sudo apt-get update -qq
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y openssh-client
elif command -v yum >/dev/null 2>&1 || command -v dnf >/dev/null 2>&1; then
echo "Using yum/dnf to install openssh-clients"
sudo yum install -y openssh-clients || sudo dnf install -y openssh-clients
elif command -v apk >/dev/null 2>&1; then
echo "Using apk to install openssh-client"
sudo apk add --no-cache openssh-client
elif command -v brew >/dev/null 2>&1; then
echo "Using Homebrew to install openssh"
brew update >/dev/null || true
brew install openssh
elif command -v pkg >/dev/null 2>&1; then
echo "Using pkg to install openssh"
sudo pkg install -y openssh
else
echo "No known package manager found to install SSH client. Please install 'ssh' and rerun." >&2
exit 1
fi
# Verify the install worked
if ! command -v ssh >/dev/null 2>&1; then
echo "Failed to install SSH client automatically — please install 'ssh' and rerun." >&2
exit 1
fi
fi
# Setup SSH private key
SSH_KEY_PATH="$HOME/.ssh/github_action_key"