Skip to content

Instantly share code, notes, and snippets.

@sople1
Last active December 22, 2019 13:46
Show Gist options
  • Select an option

  • Save sople1/c2f4cba053bddd5def1e4822381020b8 to your computer and use it in GitHub Desktop.

Select an option

Save sople1/c2f4cba053bddd5def1e4822381020b8 to your computer and use it in GitHub Desktop.
GIT: update data on post-update (local, remote)
#!/bin/bash
#
# .git/post-update
#
git update-server-info
echo "Starting Updating Process..."
# :: Auto-Pulling script >
#SERVICE_WEB_ROOT="/var/www/html/"
SERVICE_WEB_ROOT="($PUBLICHOME_PATH)"
SERVICE_DEV_ROOT="($DEVHOME_PATH)"
SSH_CONN_WEB="user@localhost"
SSH_CONN_DEV="user@localhost"
SSH_ORDER_WEB="cd $SERVICE_WEB_ROOT && git pull origin"
SSH_ORDER_DEV="cd $SERVICE_DEV_ROOT && git pull origin"
# -- Push to DEV when all Pushes are launched
echo "Push to DEV>>"
ssh $SSH_CONN_DEV $SERVICE_DEV_ROOT $SSH_ORDER_DEV
## switch by branch
branch=$(git rev-parse --symbolic --abbrev-ref $1) # $1=refname
if [ "master"=="$branch" ]; then
# -- Push to WEB when Pushed branch was 'master'
echo "Push to WEB>>"
ssh $SSH_CONN_WEB $SERVICE_WEB_ROOT $SSH_ORDER_WEB
else
echo "None updated"
fi
# echo $branch
# switch by branch > end
echo "Updating Process Completed."
# :: Auto-Pulling script > end
exec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment