Skip to content

Instantly share code, notes, and snippets.

@mandemeskel
Last active December 11, 2021 08:25
Show Gist options
  • Save mandemeskel/7d4908484526cd2c8b6ee4cbbb1b69e5 to your computer and use it in GitHub Desktop.
Save mandemeskel/7d4908484526cd2c8b6ee4cbbb1b69e5 to your computer and use it in GitHub Desktop.
Deploy an app build to a remote server with SSH and SCP.
#!/bin/sh
echo "deploying..."
# bundle, minify, and package css and js - optional
# gulp build
# using SSH vs SFTP because SSH offers us rm -rf *
# which deletes directories even if they are empty
# we don't have to traverse the directory and delete files manually
# <<EOF tells shell to give the following lines to the sftp terminal
ssh -i ~/.ssh/DEPLOY_KEY USERNAME@APP.COM <<EOF
cd build
rm -rf *
exit
EOF
# upload files from build to the remote file build
scp -r -i ~/.ssh/DEPLOY_KEY ./build/* USERNAME@APP.COM:/build/
echo "deploy finished"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment