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: password:
description: "SSH passswordIf a password is set, the secret key pair is ignored" description: "SSH passswordIf a password is set, the secret key pair is ignored"
required: false required: false
script: beforeScript:
description: "upload files before exec script"
required: false
afterScript:
description: "upload files after exec script" description: "upload files after exec script"
required: false required: false
@@ -54,7 +57,8 @@ runs:
- ${{ inputs.sftpArgs }} - ${{ inputs.sftpArgs }}
- ${{ inputs.delete_remote_files }} - ${{ inputs.delete_remote_files }}
- ${{ inputs.password }} - ${{ inputs.password }}
- ${{ inputs.script }} - ${{ inputs.beforeScript }}
- ${{ inputs.afterScript }}
branding: branding:
icon: 'upload-cloud' 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 sshpass -p ${10} ssh -o StrictHostKeyChecking=no -p $3 $1@$2 mkdir -p $6
fi 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' echo 'SFTP Start'
# create a temporary file containing sftp commands # create a temporary file containing sftp commands
printf "%s" "put -r $5 $6" >$TEMP_SFTP_FILE printf "%s" "put -r $5 $6" >$TEMP_SFTP_FILE
#-o StrictHostKeyChecking=no avoid Host key verification failed. #-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 SSHPASS=${10} sshpass -e sftp -oBatchMode=no -b $TEMP_SFTP_FILE -P $3 $8 -o StrictHostKeyChecking=no $1@$2
if [ -n "${11}" ]; then if [ -n "${12}" ]; then
echo "${11}" > $TEMP_SSH_SHELL_FILE echo "Exec After Script..."
echo "${12}" > $TEMP_SSH_SHELL_FILE
cat $TEMP_SSH_SHELL_FILE cat $TEMP_SSH_SHELL_FILE
echo Start Run Command echo Start Run Command
sh -c "sshpass -p 10 ssh -o StrictHostKeyChecking=no -p $3 $1@$2 < $TEMP_SSH_SHELL_FILE" 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 ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 mkdir -p $6
fi 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' echo 'SFTP Start'
# create a temporary file containing sftp commands # create a temporary file containing sftp commands
printf "%s" "put -r $5 $6" >$TEMP_SFTP_FILE printf "%s" "put -r $5 $6" >$TEMP_SFTP_FILE
#-o StrictHostKeyChecking=no avoid Host key verification failed. #-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 sftp -b $TEMP_SFTP_FILE -P $3 $8 -o StrictHostKeyChecking=no -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2
if [ -n "${11}" ]; then if [ -n "${12}" ]; then
echo "${11}" > $TEMP_SSH_SHELL_FILE echo "Exec After Script..."
echo "${12}" > $TEMP_SSH_SHELL_FILE
cat $TEMP_SSH_SHELL_FILE cat $TEMP_SSH_SHELL_FILE
echo Start Run Command echo Start Run Command
sh -c "ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 < $TEMP_SSH_SHELL_FILE" sh -c "ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 < $TEMP_SSH_SHELL_FILE"