diff --git a/entrypoint.sh b/entrypoint.sh index 76e167f..b2a0f62 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,21 +16,28 @@ echo "> Starting ${GITHUB_WORKFLOW}:${GITHUB_ACTION}" # echo "INPUT_RUN_AFTER: ${INPUT_RUNAFTER}" RUNBEFORE="${INPUT_RUNBEFORE/$'\n'/' && '}" -RUNAFTER="${INPUT_RUNBEFORE/$'\n'/' && '}" +RUNAFTER="${INPUT_RUNAFTER/$'\n'/' && '}" if [ -z "$INPUT_KEY" ] then # Password echo "> Exporting Password" export SSHPASS=$PASS - echo "> Executing commands before deployment" - sshpass -e ssh -o StrictHostKeyChecking=no -p $INPUT_PORT $INPUT_USER@$INPUT_HOST "$RUNBEFORE" + [[ -z "${INPUT_RUNBEFORE}" ]] && { + echo "> Executing commands before deployment" + sshpass -e ssh -o StrictHostKeyChecking=no -p $INPUT_PORT $INPUT_USER@$INPUT_HOST "$RUNBEFORE" + } + echo "> Deploying now" sshpass -p $INPUT_PASS rsync --progress -a -v -e "ssh -p $INPUT_PORT" $GITHUB_WORKSPACE/$INPUT_LOCAL $INPUT_USER@$INPUT_HOST:$INPUT_REMOTE - echo "> Executing commands after deployment" - sshpass -e ssh -o StrictHostKeyChecking=no -p $INPUT_PORT $INPUT_USER@$INPUT_HOST "$RUNAFTER" + [[ -z "${INPUT_RUNAFTER}" ]] && { + echo "> Executing commands after deployment" + sshpass -e ssh -o StrictHostKeyChecking=no -p $INPUT_PORT $INPUT_USER@$INPUT_HOST "$RUNAFTER" + } + + else # Private key pwd mkdir "/root/.ssh" @@ -46,14 +53,18 @@ else # Private key ls -lha "/root/.ssh/" - echo "> Executing commands before deployment" - sshpass -e ssh -o StrictHostKeyChecking=no -p $INPUT_PORT $INPUT_USER@$INPUT_HOST "$RUNBEFORE" + [[ -z "${INPUT_RUNBEFORE}" ]] && { + echo "> Executing commands before deployment" + sshpass -e ssh -o StrictHostKeyChecking=no -p $INPUT_PORT $INPUT_USER@$INPUT_HOST "$RUNBEFORE" + } echo "> Deploying now" sshpass -e rsync --progress -a -v -e "ssh -p $INPUT_PORT" $GITHUB_WORKSPACE/$INPUT_LOCAL $INPUT_USER@$INPUT_HOST:$INPUT_REMOTE - echo "> Executing commands after deployment" - sshpass -e ssh -o StrictHostKeyChecking=no -p $INPUT_PORT $INPUT_USER@$INPUT_HOST "$RUNAFTER" + [[ -z "${INPUT_RUNAFTER}" ]] && { + echo "> Executing commands after deployment" + sshpass -e ssh -o StrictHostKeyChecking=no -p $INPUT_PORT $INPUT_USER@$INPUT_HOST "$RUNAFTER" + } fi