diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 338ad8f..b96ab88 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -188,7 +188,12 @@ deploy_to_vps: - apk add --no-cache openssh-client # Load the SSH private key stored in the CI variable SSH_PRIVATE_KEY - eval $(ssh-agent -s) - - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + - | + if [ -f "${SSH_PRIVATE_KEY:-}" ]; then + tr -d '\r' < "$SSH_PRIVATE_KEY" | ssh-add - + else + printf '%s\n' "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + fi - mkdir -p ~/.ssh && chmod 700 ~/.ssh # Scan and trust the VPS host key (avoids manual known_hosts management) - ssh-keyscan -H $VPS_IP >> ~/.ssh/known_hosts