Skip to content

Commit

Permalink
[BUGFIX] Fix run after commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mai-space committed Mar 5, 2022
1 parent 23f713f commit 3efdae6
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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


Expand Down

0 comments on commit 3efdae6

Please sign in to comment.