Skip to content

Commit

Permalink
purge SFTP_ONLY flag
Browse files Browse the repository at this point in the history
  • Loading branch information
maaaathis committed Aug 18, 2024
1 parent 9cc8eb3 commit 9fd5767
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
5 changes: 0 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ inputs:
remote_path:
description: 'The remote directory path where the files will be uploaded.'
required: true
sftp_only:
description: 'If set to true, the connection will be made via the SFTP protocol only.'
required: false
default: false
sftpArgs:
description: 'Additional arguments for the SFTP command.'
required: false
Expand All @@ -47,7 +43,6 @@ runs:
- ${{ inputs.ssh_private_key }}
- ${{ inputs.local_path }}
- ${{ inputs.remote_path }}
- ${{ inputs.sftp_only }}
- ${{ inputs.sftpArgs }}
- ${{ inputs.delete_remote_files }}
- ${{ inputs.password }}
Expand Down
23 changes: 3 additions & 20 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ PORT="$3"
SSH_PRIVATE_KEY="$4"
LOCAL_PATH="$5"
REMOTE_PATH="$6"
SFTP_ONLY="$7"
SFTP_ARGS="$8"
DELETE_REMOTE_FILES="$9"
PASSWORD="${10}"
SFTP_ARGS="$7"
DELETE_REMOTE_FILES="$8"
PASSWORD="${9}"

# Define temporary file paths
TEMP_SSH_PRIVATE_KEY_FILE='../private_key.pem'
Expand All @@ -36,14 +35,6 @@ if [ -n "$PASSWORD" ]; then
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -p "$PORT" "$USERNAME@$SERVER" rm -rf "$REMOTE_PATH"
fi

# Skip directory creation if SFTP_ONLY is true, otherwise create directory
if [ "$SFTP_ONLY" != "true" ]; then
echo 'Creating directory on remote server if it does not exist...'
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -p "$PORT" "$USERNAME@$SERVER" mkdir -p "$REMOTE_PATH"
else
echo 'Skipping directory creation as SFTP_ONLY is set to true'
fi

# Start SFTP transfer
echo 'Starting SFTP transfer...'
printf "%s" "put -r $LOCAL_PATH $REMOTE_PATH" >"$TEMP_SFTP_FILE"
Expand All @@ -64,14 +55,6 @@ if [ "$DELETE_REMOTE_FILES" = "true" ]; then
ssh -o StrictHostKeyChecking=no -p "$PORT" -i "$TEMP_SSH_PRIVATE_KEY_FILE" "$USERNAME@$SERVER" rm -rf "$REMOTE_PATH"
fi

# Skip directory creation if SFTP_ONLY is true, otherwise create directory
if [ "$SFTP_ONLY" != "true" ]; then
echo 'Creating directory on remote server if it does not exist...'
ssh -o StrictHostKeyChecking=no -p "$PORT" -i "$TEMP_SSH_PRIVATE_KEY_FILE" "$USERNAME@$SERVER" mkdir -p "$REMOTE_PATH"
else
echo 'Skipping directory creation as SFTP_ONLY is set to true'
fi

# Start SFTP transfer
echo 'Starting SFTP transfer...'
printf "%s" "put -r $LOCAL_PATH $REMOTE_PATH" >"$TEMP_SFTP_FILE"
Expand Down

0 comments on commit 9fd5767

Please sign in to comment.