Skip to content

Instantly share code, notes, and snippets.

@BrandonRomano
Created September 22, 2016 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrandonRomano/b2720ddf58e4ee1acb9d15fc80926251 to your computer and use it in GitHub Desktop.
Save BrandonRomano/b2720ddf58e4ee1acb9d15fc80926251 to your computer and use it in GitHub Desktop.
sftp_user=""
sftp_host=""
deploy() {
local write_file="sftp-commands-$(date +%s).txt"
generate_command_file > "$write_file"
cat "$write_file" | sftp "$sftp_user"@"$sftp_host"
rm "$write_file"
}
generate_command_file() {
echo "mkdir deploy"
echo "cd deploy"
find . -print0 | while IFS= read -r -d '' file
do
if [[ -d "$file" && "$file" != "." ]]; then
echo "mkdir $file"
elif [[ -f "$file" ]]; then
local perms=$(stat -f '%A %a %N' gulpfile.js | cut -f1 -d " ")
echo "put $file $file"
echo "chmod $perms $file"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment