sh 当git autodeploy脚本与字符串“[deploy]”匹配时

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 当git autodeploy脚本与字符串“[deploy]”匹配时相关的知识,希望对你有一定的参考价值。

#!/bin/sh
#
# git autodeploy script when it matches the string "[deploy]"
#
# @author    icyleaf <icyleaf.cn@gmail.com>
# @link      http://icyleaf.com
# @version   0.1
#
# Usage:
#       1. put this into the post-receive hook file itself below
#       2. `chmod +x post-recive` 
#       3. Done!

# Check the remote git repository whether it is bare
IS_BARE=$(git rev-parse --is-bare-repository)
if [ -z "$IS_BARE" ]; then
	echo >&2 "fatal: post-receive: IS_NOT_BARE"
	exit 1
fi

# Get the latest commit subject
SUBJECT=$(git log -1 --pretty=format:"%s")

# Deploy the HEAD sources to publish
IS_PULL=$(echo "$SUBJECT" | grep "\[deploy\]")
if [ -z "$IS_PULL" ]; then
	echo >&2 "tips: post-receive: IS_NOT_PULL"
	exit 1
fi

# Check the deploy dir whether it exists
DEPLOY_DIR=/home/icyleaf/php/icyleaf/
if [ ! -d $DEPLOY_DIR ] ; then
	echo >&2 "fatal: post-receive: DEPLOY_DIR_NOT_EXIST: \"$DEPLOY_DIR\""
	exit 1
fi

# Check the deploy dir whether it is git repository
#
#IS_GIT=$(git rev-parse --git-dir 2>/dev/null)
#if [ -z "$IS_GIT" ]; then
#	echo >&2 "fatal: post-receive: IS_NOT_GIT"
#	exit 1
#fi

# Goto the deploy dir and pull the latest sources
cd $DEPLOY_DIR
#env -i git reset --hard
env -i git pull

以上是关于sh 当git autodeploy脚本与字符串“[deploy]”匹配时的主要内容,如果未能解决你的问题,请参考以下文章

sh jboss_AutoDeploy.sh

linux下实现自动部署tomcat的脚本

git clone下代码window与unix换行问题

在 Git Bash 中运行 .sh 脚本

sh gogit,git创建脚本

sh Git脚本