From 7107e3d999897d66030d289cd08b16b33ae765f6 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Tue, 15 Aug 2023 10:14:35 +0200 Subject: [PATCH] check if clone was successful --- app.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app.sh b/app.sh index ea18bf9..ee838dd 100644 --- a/app.sh +++ b/app.sh @@ -1,12 +1,10 @@ #!/bin/bash - GIT_REPO_PATH=$(mktemp -d) +GIT_REPO_PATH=$(mktemp -d) - git config --global user.email "$GIT_USER_MAIL" - git config --global user.name "$GIT_USERNAME" +git config --global user.email "$GIT_USER_MAIL" +git config --global user.name "$GIT_USERNAME" - echo "[INFO] clone repository..." - GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -i $GIT_REPO_DEPLOY_KEY" git clone "$GIT_REPO_URL" "$GIT_REPO_PATH" --quiet > /dev/null echo "[INFO] check variables..." if [ -z "$GIT_REPO_DEPLOY_KEY" ] ; then echo "[ERROR] \$GIT_REPO_DEPLOY_KEY is not set." @@ -41,7 +39,13 @@ if [ -z "$DEVICES" ] ; then exit 3 fi +echo "[INFO] clone repository..." +if GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -i $GIT_REPO_DEPLOY_KEY" git clone "$GIT_REPO_URL" "$GIT_REPO_PATH" --quiet > /dev/null; then cd "$GIT_REPO_PATH" || exit +else + echo "[ERROR] Failed to clone repository." + exit 1 +fi while true ; do echo "[INFO] pull repository..."