feat: check for SSH, attempt install via package manager if missing
This commit is contained in:
parent
a5027e414c
commit
c54d7dfa89
1 changed files with 40 additions and 0 deletions
40
action.yml
40
action.yml
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue