mirror of
https://gitee.com/jack_whh/SFTP-Deploy-Action.git
synced 2026-03-09 23:12:55 +08:00
Add an option named sftp_only to connect via sftp only
This commit is contained in:
@@ -33,8 +33,13 @@ sftp srever port , default `22`
|
|||||||
**Required** `local_path` of you project, if you want put single file:use path like `./myfile`, if you want put directory: use path like `./static/*`, it will put all files under `static` directory. Default to `./*`(will put all files in your repo).
|
**Required** `local_path` of you project, if you want put single file:use path like `./myfile`, if you want put directory: use path like `./static/*`, it will put all files under `static` directory. Default to `./*`(will put all files in your repo).
|
||||||
|
|
||||||
### `remote_path`
|
### `remote_path`
|
||||||
|
|
||||||
**Required** remote_path
|
**Required** remote_path
|
||||||
|
|
||||||
|
### `sftp_only`
|
||||||
|
|
||||||
|
connection via sftp protocol only, the default value is `false`. If your port only accepts the sftp protocol, set this option to `true`. However, please note that when this option is set to `true`, the remote folder will not be created automatically.
|
||||||
|
|
||||||
### `args`
|
### `args`
|
||||||
args of sftp cmd, E.g.`-o ConnectTimeout=5`
|
args of sftp cmd, E.g.`-o ConnectTimeout=5`
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ inputs:
|
|||||||
description: 'files will copy to under remote_path'
|
description: 'files will copy to under remote_path'
|
||||||
required: true
|
required: true
|
||||||
default: /
|
default: /
|
||||||
|
sftp_only:
|
||||||
|
description: 'connection via sftp protocol only'
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
|
||||||
args:
|
args:
|
||||||
description: 'sftp args'
|
description: 'sftp args'
|
||||||
@@ -39,6 +43,7 @@ runs:
|
|||||||
- ${{ inputs.ssh_private_key }}
|
- ${{ inputs.ssh_private_key }}
|
||||||
- ${{ inputs.local_path }}
|
- ${{ inputs.local_path }}
|
||||||
- ${{ inputs.remote_path }}
|
- ${{ inputs.remote_path }}
|
||||||
|
- ${{ inputs.sftp_only }}
|
||||||
- ${{ inputs.args }}
|
- ${{ inputs.args }}
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
|
|||||||
@@ -12,15 +12,19 @@ printf "%s" "$4" >$TEMP_SSH_PRIVATE_KEY_FILE
|
|||||||
# avoid Permissions too open
|
# avoid Permissions too open
|
||||||
chmod 600 $TEMP_SSH_PRIVATE_KEY_FILE
|
chmod 600 $TEMP_SSH_PRIVATE_KEY_FILE
|
||||||
|
|
||||||
echo 'ssh start'
|
if test $7 = "true"; then
|
||||||
|
echo "Connection via sftp protocol only, skip the command to create a directory"
|
||||||
|
else
|
||||||
|
echo 'ssh start'
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
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 $7 -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
|
||||||
|
|
||||||
echo 'deploy success'
|
echo 'deploy success'
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user