I have the following script as a post-receive
git hook on the server. It is meant to automate the deployment whenever a git push is made.
#!/bin/bash
DEPLOYMENT_BRANCH=dev
WORKING_DIR=/300gb/project
while read oldrev newrev refname
do
# there can be multiple branches but we're only interested in deploy
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "$DEPLOYMENT_BRANCH" == "$branch" ]; then
echo "**** pulling changes from $branch ****"
# change directory to the working copy
cd $WORKING_DIR
unset GIT_DIR
git fetch
git reset --hard origin/$DEPLOYMENT_BRANCH
# at this point you have the latest source in WORKING_DIR.
# time to start your build process and deployment scripts
# grunt, for instance
yarn install
yarn run doc
forever restartall
fi
done
But when I made the push from my local machine to the dev
branch, nothing happened. The script was never invoked. What could be the reason for this? I have changed the permission of the hook to 777
.