From 39b26e92665d5e9df014645f7bdb936772deb53e Mon Sep 17 00:00:00 2001 From: wdhcr Date: Fri, 19 Sep 2025 14:17:27 +0800 Subject: [PATCH] update --- action.yml | 8 ++++++-- entrypoint.sh | 26 ++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 05c1335..c494715 100644 --- a/action.yml +++ b/action.yml @@ -36,7 +36,10 @@ inputs: password: description: "SSH passsword,If 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' diff --git a/entrypoint.sh b/entrypoint.sh index 311998c..6df3108 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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"