From 7ebcd5452ec4cd33879ba371d2cf62f6c0c10484 Mon Sep 17 00:00:00 2001 From: WinterMyst <22961076-wintermyst@users.noreply.gitlab.com> Date: Sun, 22 Sep 2024 17:16:04 +0000 Subject: [PATCH] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 29f8479..e977e6c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,7 +38,23 @@ release: - mkdir -p ~/.ssh - chmod 700 ~/.ssh # Decode and set up the SSH private key - - echo "$SSH_PRIVATE_KEY_ENCODED" | base64 -d > ~/.ssh/id_rsa + - | + printf '%s' "$SSH_PRIVATE_KEY_BASE64" | tr -d '\r\n' | base64 --decode > ~/.ssh/id_rsa + if [ $? -ne 0 ]; then + echo "Error: Failed to decode SSH_PRIVATE_KEY_BASE64." + exit 1 + fi + # Verify the key file + if [ ! -s ~/.ssh/id_rsa ]; then + echo "Error: SSH private key file is empty or does not exist." + exit 1 + fi + ssh-keygen -y -f ~/.ssh/id_rsa > /dev/null + if [ $? -ne 0 ]; then + echo "Error: Invalid SSH private key." + exit 1 + fi + # Set permissions - chmod 600 ~/.ssh/id_rsa # Start the SSH agent and add the key - eval $(ssh-agent -s)