有没有办法接受post-receive中发布分支下的任何分支?
is there a way to accept any branch under the release branch in post-receive?
我目前正在推送到这个接受服务器,每次我创建一个新版本时,我都必须更改代码第 4 行接受的 BRANCH,我该怎么做才能让任何东西到来从发布/被接受?我在想像 BRANCH=release/* 这样的东西行得通吗?
#!/bin/bash
TARGET="<path_to_site>"
GIT_DIR="<path_to_repo>"
BRANCH="release/1.7"
while read oldrev newrev ref
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
else
echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
fi
done
您可以在 Bash 中使用 ==
运算符在 if
语句中进行正则表达式比较:
if [[ $ref == *"release/"* ]];
then
# ...
else
# ...
fi
这将匹配任何包含字符串 "release/"
的引用,例如 "refs/heads/release/1.7"
.
我目前正在推送到这个接受服务器,每次我创建一个新版本时,我都必须更改代码第 4 行接受的 BRANCH,我该怎么做才能让任何东西到来从发布/被接受?我在想像 BRANCH=release/* 这样的东西行得通吗?
#!/bin/bash
TARGET="<path_to_site>"
GIT_DIR="<path_to_repo>"
BRANCH="release/1.7"
while read oldrev newrev ref
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
else
echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
fi
done
您可以在 Bash 中使用 ==
运算符在 if
语句中进行正则表达式比较:
if [[ $ref == *"release/"* ]];
then
# ...
else
# ...
fi
这将匹配任何包含字符串 "release/"
的引用,例如 "refs/heads/release/1.7"
.