This commit is contained in:
2025-09-19 14:17:27 +08:00
parent 43a1219c6c
commit 39b26e9266
2 changed files with 28 additions and 6 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

@@ -29,14 +29,23 @@ 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 "${11}" ]; then
echo "${11}" > $TEMP_SSH_SHELL_FILE
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"
@@ -64,14 +73,23 @@ 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
if [ -n "${11}" ]; then
echo "${11}" > $TEMP_SSH_SHELL_FILE
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"