fixed if condition

This commit is contained in:
smf
2024-03-08 17:59:30 +08:00
parent 49e8128b8c
commit 7ad91c6132

View File

@@ -1,35 +1,31 @@
#!/bin/sh
set -eu
if [ -z "${INPUT_REMOTE_DOCKER_PORT+x}" ]; then
if [ -z "${INPUT_REMOTE_DOCKER_PORT+x}" ] || [ -z "$INPUT_REMOTE_DOCKER_PORT" ]; then
INPUT_REMOTE_DOCKER_PORT=22
fi
if [ -z "${INPUT_REMOTE_DOCKER_HOST+x}" ]; then
if [ -z "${INPUT_REMOTE_DOCKER_HOST+x}" ] || [ -z "$INPUT_REMOTE_DOCKER_HOST" ]; then
echo "Input remote_docker_host is required!"
exit 1
fi
if [ -z "${INPUT_REMOTE_DOCKER_USER+x}" ]; then
if [ -z "${INPUT_REMOTE_DOCKER_USER+x}" ] || [ -z "$INPUT_REMOTE_DOCKER_USER" ]; then
echo "Input remote_docker_user is required!"
exit 1
fi
if [ -z "${INPUT_SSH_PRIVATE_KEY+x}" ]; then
if [ -z "${INPUT_SSH_PRIVATE_KEY+x}" ] || [ -z "$INPUT_SSH_PRIVATE_KEY" ]; then
echo "Input ssh_private_key is required!"
exit 1
fi
if [ -z "${INPUT_ARGS+x}" ]; then
if [ -z "${INPUT_ARGS+x}" ] || [ -z "$INPUT_ARGS" ]; then
echo "Input input_args is required!"
exit 1
fi
CHANGE_DIR=true
if [ -z "${INPUT_DEPLOY_PATH+x}" ]; then
CHANGE_DIR=false
fi
if $CHANGE_DIR ; then
if ! [ -z "${INPUT_DEPLOY_PATH+x}" ] && ! [ -z "$INPUT_DEPLOY_PATH" ]; then
echo "Change working directory"
echo "Current: `pwd`"
echo "Target: $INPUT_DEPLOY_PATH"
@@ -38,7 +34,7 @@ if $CHANGE_DIR ; then
cd $INPUT_DEPLOY_PATH
fi
if [ -z "${INPUT_DOCKER_REGISTRY_URI+x}" ]; then
if [ -z "${INPUT_DOCKER_REGISTRY_URI+x}" ] || [ -z "$INPUT_DOCKER_REGISTRY_URI" ]; then
INPUT_DOCKER_REGISTRY_URI=https://registry.hub.docker.com
fi
@@ -52,10 +48,6 @@ chmod 600 ~/.ssh/id_rsa
eval $(ssh-agent)
ssh-add ~/.ssh/id_rsa
SSH_PROXY=true
if [ -z "${INPUT_SSH_PROXY_CMD+x}" ]; then
SSH_PROXY=false
fi
echo "Add REMOTE_DOCKER_HOST alias to ~/.ssh/config"
touch ~/.ssh/config
echo >> ~/.ssh/config
@@ -66,7 +58,7 @@ echo " Port $INPUT_REMOTE_DOCKER_PORT" >> ~/.ssh/config
echo " IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config
echo " StrictHostKeyChecking no" >> ~/.ssh/config
echo " UserKnownHostsFile /dev/null" >> ~/.ssh/config
if $SSH_PROXY ; then
if ! [ -z "${INPUT_SSH_PROXY_CMD+x}" ] && ! [ -z "$INPUT_SSH_PROXY_CMD" ]; then
echo "Add ProxyCommand: $INPUT_SSH_PROXY_CMD"
echo " ProxyCommand $INPUT_SSH_PROXY_CMD" >> ~/.ssh/config
fi