m5x2 #2

Merged
smf merged 32 commits from m5x2 into local 2024-03-08 18:15:54 +08:00
Showing only changes of commit 7ad91c6132 - Show all commits

View File

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