7 Commits

Author SHA1 Message Date
39b26e9266 update 2025-09-19 14:17:27 +08:00
JackWhh
43a1219c6c 1
Signed-off-by: JackWhh <5264499+jack_whh@user.noreply.gitee.com>
2024-07-19 05:57:37 +00:00
JackWhh
793651ed95 1
Signed-off-by: JackWhh <5264499+jack_whh@user.noreply.gitee.com>
2024-07-19 05:51:05 +00:00
JackWhh
09f19123fd 1
Signed-off-by: JackWhh <5264499+jack_whh@user.noreply.gitee.com>
2024-07-19 04:00:42 +00:00
JackWhh
ad4d3f8f0f 1
Signed-off-by: JackWhh <5264499+jack_whh@user.noreply.gitee.com>
2024-07-19 03:59:00 +00:00
JackWhh
68a77af17d 1
Signed-off-by: JackWhh <5264499+jack_whh@user.noreply.gitee.com>
2024-07-19 03:54:06 +00:00
JackWhh
244c6725be 1
Signed-off-by: JackWhh <5264499+jack_whh@user.noreply.gitee.com>
2024-07-19 03:49:37 +00:00
2 changed files with 36 additions and 21 deletions

View File

@@ -36,7 +36,10 @@ inputs:
password:
description: "SSH passswordIf a password is set, the secret key pair is ignored"
required: false
script:
beforeScript:
description: "upload files before exec script"
required: false
afterScript:
description: "upload files after exec script"
required: false
@@ -54,7 +57,8 @@ runs:
- ${{ inputs.sftpArgs }}
- ${{ inputs.delete_remote_files }}
- ${{ inputs.password }}
- ${{ inputs.script }}
- ${{ inputs.beforeScript }}
- ${{ inputs.afterScript }}
branding:
icon: 'upload-cloud'

View File

@@ -4,6 +4,7 @@
set -eu
TEMP_SSH_PRIVATE_KEY_FILE='../private_wdhcr.pem'
TEMP_SSH_SHELL_FILE='../depoly_wdhcr.sh'
TEMP_SFTP_FILE='../sftp'
# make sure remote path is not empty
@@ -28,12 +29,27 @@ if [ -z != ${10} ]; then
sshpass -p ${10} ssh -o StrictHostKeyChecking=no -p $3 $1@$2 mkdir -p $6
fi
if [ -n "${11}" ]; then
echo "Exec Before Script..."
echo "${11}" > $TEMP_SSH_SHELL_FILE
cat $TEMP_SSH_SHELL_FILE
echo Start Run Command
sh -c "sshpass -p 10 ssh -o StrictHostKeyChecking=no -p $3 $1@$2 < $TEMP_SSH_SHELL_FILE"
fi
echo 'SFTP Start'
# create a temporary file containing sftp commands
printf "%s" "put -r $5 $6" >$TEMP_SFTP_FILE
#-o StrictHostKeyChecking=no avoid Host key verification failed.
SSHPASS=${10} sshpass -e sftp -oBatchMode=no -b $TEMP_SFTP_FILE -P $3 $8 -o StrictHostKeyChecking=no $1@$2
if [ -n "${12}" ]; then
echo "Exec After Script..."
echo "${12}" > $TEMP_SSH_SHELL_FILE
cat $TEMP_SSH_SHELL_FILE
echo Start Run Command
sh -c "sshpass -p 10 ssh -o StrictHostKeyChecking=no -p $3 $1@$2 < $TEMP_SSH_SHELL_FILE"
fi
echo 'Deploy Success'
exit 0
@@ -57,31 +73,26 @@ else
ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 mkdir -p $6
fi
if [ -n "${11}" ]; then
echo "Exec Before Script..."
echo "${11}" > $TEMP_SSH_SHELL_FILE
cat $TEMP_SSH_SHELL_FILE
echo Start Run Command
sh -c "ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 < $TEMP_SSH_SHELL_FILE"
fi
echo 'SFTP Start'
# create a temporary file containing sftp commands
printf "%s" "put -r $5 $6" >$TEMP_SFTP_FILE
#-o StrictHostKeyChecking=no avoid Host key verification failed.
sftp -b $TEMP_SFTP_FILE -P $3 $8 -o StrictHostKeyChecking=no -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2
echo $11
echo "-----"
echo ${11}
if [ -z != ${11} ]; then
echo $11
script=$11
echo $script
echo "------"
ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 "$script"
echo "-----"
script1="./usr/local/transport-api/restart.sh restart"
echo $script1
ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 "$script1"
echo "-----"
script2="sh /usr/local/transport-api/restart.sh restart"
echo $scscript2ript
ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 "$script2"
echo "-----"
if [ -n "${12}" ]; then
echo "Exec After Script..."
echo "${12}" > $TEMP_SSH_SHELL_FILE
cat $TEMP_SSH_SHELL_FILE
echo Start Run Command
sh -c "ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 < $TEMP_SSH_SHELL_FILE"
fi
echo 'Deploy Success'
exit 0