我当前正在推送到此接受服务器,并且每次创建新版本时,都必须更改代码第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
答案 0 :(得分:0)
您可以在Bash中使用==
运算符在if
语句中进行正则表达式比较:
if [[ $ref == *"release/"* ]];
then
# ...
else
# ...
fi
这将匹配包含字符串"release/"
的任何引用,例如"refs/heads/release/1.7"
。