我有一个Webapp,托管在Webfaction上。我的目标是每次我将一些代码推送到master分支时都更新我的临时存储库。
所以,我的应用程序的结构如下:
- webapps/staging/ (Actual contents of the app running on my server)
- webapps/staging/run (My run scripts)
- webapps/git/repos/staging.git (my bare git, which includes my hooks)
我还通过指出我的GitHub存储库来创建了一个名为“ staging”的远程git服务器
我的接收后挂钩看起来像这样:
#!/bin/bash
TARGET="/home/username/webapps/staging/"
GIT_DIR="/home/username/webapps/git/repos/staging.git"
BRANCH="master"
while read oldrev newrev ref
echo "It started"
do
# only checking out the master (or whatever branch you would like to deploy)
if [ "$ref" = "refs/heads/$BRANCH" ];
then
echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH
else
echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
fi
done
是的,我允许我的接收后挂钩:
chmod +x hooks/post-receive
因此,当前,每当执行“ git push staging master”时,我都会收到“一切都是最新的”消息,但没有其他反应。它不会更新我的/ webapps / staging文件夹,并且我的回声均无效。而且我不知道我缺少哪一块。