Skip to content

Instantly share code, notes, and snippets.

@arnabdas
Created February 24, 2017 18:17
Show Gist options
  • Save arnabdas/5b44aec4e69bc4e171363c0d2d634848 to your computer and use it in GitHub Desktop.
Save arnabdas/5b44aec4e69bc4e171363c0d2d634848 to your computer and use it in GitHub Desktop.
Deploy with rsync
#!/bin/bash
# Run with the command: `./deploy.sh live go`
$SERVER_IP="xx.xx.xx.xx"
$ERRORSTRING="Error. Please make sure you've indicated correct parameters"
cd ./public
if [ $# -eq 0 ]
then
echo $ERRORSTRING;
elif [ $1 == "live" ]
then
if [[ -z $2 ]]
then
echo "Running dry-run"
rsync --dry-run -az --force --delete --progress -e "ssh -p22 -i /home/gitlab-runner/.ssh/id_rsa " ./ build@{$SERVER_IP}:/usr/share/nginx/html
elif [ $2 == "go" ]
then
echo "Running actual deploy"
rsync -az --force --delete --progress -e "ssh -p22 -i /home/gitlab-runner/.ssh/id_rsa " ./ build@{$SERVER_IP}:/usr/share/nginx/html
else
echo $ERRORSTRING;
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment