Skip to content

Instantly share code, notes, and snippets.

@dokicro dokicro/script
Last active Oct 25, 2018

Embed
What would you like to do?
Automated Vue deployment to the server via ssh
#!/bin/bash
SSH_SERVER="user@website"
DEPLOY_PATH="/var/www/website"
DEPLOY_MODE="production"
echo "Building file"
npm run build
echo 'Compressing to dist'
tar -czf dist.gz dist
echo 'Cleaning temp folder and creating new'
ssh ${SSH_SERVER} "
rm -rf ${DEPLOY_PATH}-temp
mkdir -p ${DEPLOY_PATH}
mkdir -p ${DEPLOY_PATH}-temp
";
echo 'Transfering dist.gz to server'
scp dist.gz wg.zknft.co:${DEPLOY_PATH}-temp
echo "Removing dist.gz locally"
rm -rf dist.gz
echo "Connecting to server"
ssh ${SSH_SERVER} "
echo 'Uncompressing dist.gz'
cd ${DEPLOY_PATH}-temp;
tar -xzf dist.gz
echo 'Deleting dist.gz on server'
rm -rf dist.gz
echo 'Renaming live server to old'
mv ${DEPLOY_PATH} ${DEPLOY_PATH}-old
echo 'Moving temp file to live'
mv ${DEPLOY_PATH}-temp/dist ${DEPLOY_PATH}
echo 'Removing old dist'
rm -rf ${DEPLOY_PATH}-old
echo 'Removing temp'
rm -rf ${DEPLOY_PATH}-temp
";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.