1

I'm trying to make git auto deploy to different directories depending on a branch that was pushed. I have a remote bare repository, local repository and two directories where I whant the data to be deployed and updated with each push from local to remote repository. I've added post-update hook:

#!/bin/sh


echo $1
echo "*UPDATE*"


case " $1 " in
*'refs/heads/develop'*)
        GIT_WORK_TREE=/home/git/public_html/example_deploy_dev git checkout develop webroot
        echo
        echo "Dev was pulled"
        echo
        ;;
esac

case " $1 " in
*'refs/heads/master'*)
        GIT_WORK_TREE=/home/git/public_html/example_deploy git checkout master webroot
        echo
        echo "Master was pulled"
        echo
        ;;
esac

It deploys just fine on first file creation, but doesn't update it when it's changed in directories which shold be deployed. Where do I miss smth? Thanks!

4

2 回答 2

0

尝试:

结帐-f

#! /bin/sh

update_master() {
    GIT_WORK_TREE=/home/git/public_html/example_deploy_dev git checkout -f master -- webroot
}

update_develop() {
    GIT_WORK_TREE=/home/git/public_html/example_deploy_dev git checkout -f develop -- webroot
}
for ref do
    case "$ref" in
    refs/heads/master) update_master;;
    refs/heads/test) update_test;;
    *) ;; # ignore other branches
    esac
done
于 2015-11-24T01:02:46.203 回答
0

后更新挂钩的常用脚本是:

#! /bin/sh

update_master() {
    GIT_WORK_TREE=/home/git/public_html/example_deploy_dev git checkout master -- webroot
}

update_develop() {
    GIT_WORK_TREE=/home/git/public_html/example_deploy_dev git checkout develop -- webroot
}
for ref do
    case "$ref" in
    refs/heads/master) update_master;;
    refs/heads/test) update_test;;
    *) ;; # ignore other branches
    esac
done

由于该钩子“采用可变数量的参数,每个参数都是实际更新的 ref 的名称。”,你不能只依赖$1.

于 2015-09-25T06:10:47.050 回答