Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if the script is in the remote host and copy if not #12

Merged
merged 15 commits into from
Jun 30, 2022
Merged
17 changes: 15 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fi

# post deploy script
if [[ -n ${INPUT_SCRIPT} ]]; then
SCRIPT="&& sh ${INPUT_SCRIPT}";
SCRIPT="&& sh ${INPUT_SCRIPT}";
else
SCRIPT=""
fi
Expand All @@ -95,7 +95,20 @@ echo "!!! MASTER SSH CONNECTION ESTABLISHED !!!"
rsync --rsh="ssh -v -p 22 -i ${WPE_SSHG_KEY_PRIVATE_PATH} -o StrictHostKeyChecking=no -o 'ControlPath=$SSH_PATH/ctl/%C'" $INPUT_FLAGS --exclude-from='/exclude.txt' $SRC_PATH "$WPE_DESTINATION"

# post deploy script and cache clear
if [[ -n ${SCRIPT} || -n ${CACHE_CLEAR} ]]; then
if [[ -n ${SCRIPT} || -n ${CACHE_CLEAR} ]]; then

if [[ -n ${SCRIPT} ]]; then
if ! ssh -v -p 22 -i ${WPE_SSHG_KEY_PRIVATE_PATH} -o StrictHostKeyChecking=no -o ControlPath="$SSH_PATH/ctl/%C" $WPE_FULL_HOST "test -s sites/${WPE_ENV_NAME}/${INPUT_SCRIPT}"; then
status=1
fi

if [[ $status -ne 0 && -f ${INPUT_SCRIPT} ]]; then
ssh -v -p 22 -i ${WPE_SSHG_KEY_PRIVATE_PATH} -o StrictHostKeyChecking=no -o ControlPath="$SSH_PATH/ctl/%C" $WPE_FULL_HOST "mkdir -p sites/${WPE_ENV_NAME}/$(dirname ${INPUT_SCRIPT})"

rsync --rsh="ssh -v -p 22 -i ${WPE_SSHG_KEY_PRIVATE_PATH} -o StrictHostKeyChecking=no -o 'ControlPath=$SSH_PATH/ctl/%C'" ${INPUT_SCRIPT} wpe_gha+"$WPE_SSH_USER":sites/"$WPE_ENV_NAME"/$(dirname ${INPUT_SCRIPT})
fi
fi

ssh -v -p 22 -i ${WPE_SSHG_KEY_PRIVATE_PATH} -o StrictHostKeyChecking=no -o ControlPath="$SSH_PATH/ctl/%C" $WPE_FULL_HOST "cd sites/${WPE_ENV_NAME} ${SCRIPT} ${CACHE_CLEAR}"
fi

Expand Down