我将以下脚本作为服务器上的post-receive
git挂钩。它意味着无论何时进行git推送都会自动部署。
#!/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
但是当我从本地机器推送到dev
分支时,没有任何反应。从未调用该脚本。这可能是什么原因?我已将挂钩的权限更改为777
。