|
@@ -1,11 +1,11 @@
|
|
|
#!/bin/bash
|
|
|
# Usage:
|
|
|
-# deploy all(skip installed stack): ./$1
|
|
|
-# deploy & upgrade: ./$1 --upgrade
|
|
|
-# deploy force(rm stack, then deploy) ./$1 --force
|
|
|
-# deploy specify app: ./$1 --module="modle1,module2,module3"
|
|
|
-# deploy to specify env: ./$1 --env="test"
|
|
|
-
|
|
|
+# deploy all(skip installed stack): ./$1
|
|
|
+# deploy & upgrade: ./$1 --upgrade
|
|
|
+# deploy force(rm stack, then deploy) ./$1 --force
|
|
|
+# deploy specify app: ./$1 --module="modle1,module2,module3"
|
|
|
+# deploy to specify env: ./$1 --env="test"
|
|
|
+# deploy with specify git branch, default master ./$1 --git-branch="dev"
|
|
|
|
|
|
|
|
|
# deploy base dir
|
|
@@ -35,7 +35,7 @@ cat <<'EOF'
|
|
|
EOF
|
|
|
# if no select, use defult
|
|
|
[ -n "$DEPLOY_APP" ] && APP=$DEPLOY_APP && \
|
|
|
- echo "start to deploy app: $APP" && echo
|
|
|
+ echo "start to deploy app: $APP" && echo
|
|
|
|
|
|
|
|
|
# git address
|
|
@@ -52,13 +52,40 @@ if [ -d ${WORKDIR}/wisecloud-catalog/.git ]; then
|
|
|
git --no-pager log --graph \
|
|
|
--pretty=format:'%h - %d% %s (%cr [%an])' \
|
|
|
--abbrev-commit --date=relative -20
|
|
|
- echo;echo
|
|
|
- git fetch --all
|
|
|
- git reset --hard origin/master
|
|
|
+ echo
|
|
|
else
|
|
|
git clone $GIT_TEMPLATE_URL ${WORKDIR}/wisecloud-catalog
|
|
|
+ cd ${WORKDIR}/wisecloud-catalog
|
|
|
+fi
|
|
|
+
|
|
|
+# fetch remote tags
|
|
|
+git fetch --all
|
|
|
+
|
|
|
+GIT_BRANCH=`echo $* | xargs -n 1 | grep "\-git\-branch" | awk -F"=" '{print $2}' | tr ',' ' '`
|
|
|
+GIT_BRANCH=${GIT_BRANCH:-master}
|
|
|
+
|
|
|
+# has branch
|
|
|
+if git branch -a | grep -wq "${GIT_BRANCH}"; then
|
|
|
+
|
|
|
+ # if current branch not the wanted, checkout it
|
|
|
+ current_branch=`git branch | grep "\*" | awk '{print $2}'`
|
|
|
+ if [ "${GIT_BRANCH}" != "${current_branch}" ]; then
|
|
|
+ # checkout
|
|
|
+ git checkout -b ${GIT_BRANCH}
|
|
|
+ fi
|
|
|
+
|
|
|
+ # reset hard the branch
|
|
|
+ git reset --hard origin/${GIT_BRANCH}
|
|
|
+
|
|
|
+# no branch
|
|
|
+else
|
|
|
+ echo "#####################################"
|
|
|
+ echo "Please specify the right \"--git-branch\", exit!"
|
|
|
+ echo "#####################################"
|
|
|
+ exit 1
|
|
|
fi
|
|
|
|
|
|
+
|
|
|
ENV=`echo $* | xargs -n 1 | grep "\-env" | awk -F"=" '{print $2}' | tr ',' ' '`
|
|
|
echo "deploy to env=$ENV"
|
|
|
if [ "$ENV" == "powercloudtest" ]; then
|