我已经玩 Hooks有一段时间了,但我似乎无法理解post-receive
hook 以我需要的方式工作。
我正在尝试获取post-receive
在我将更改推送到存储库后,创建一个 zip 文件夹并将其放置在 git 存储库文件夹之外的某个位置。
您有一个通过 post-receive 挂钩部署 zip 的好例子本文 http://blog.danielbyrne.net/2012/02/a-quick-and-easy-way-to-deploy-from-git-with-post-commit-hooks/ from 丹尼尔·伯恩 http://blog.danielbyrne.net/:
这个想法是使用git archive --format=zip http://git-scm.com/docs/git-archive:
#!/bin/bash
#
# A post commit hook that takes any updates pushed to the 'release' branch
# and creates a release directory for the new version under the webroot.
# Live site is then symlinked to this new release directory.
oldrev=$1
newrev=$2
branch=$3
# this is the root of the website (a symlink to a release directory)
webroot=/var/www/danielbyrne.net/www
if [ "$branch" == "release" ]
then
# create a release directory to extract files into
target=/var/www/danielbyrne.net/releases/$2/
mkdir $target
echo "Making target directory: $target"
# create an archive in the webroot of danielbyrne.net
/usr/bin/git archive master --format zip --output $target/deploy.zip
echo "unzipping archive..."
# extract the archive
unzip -o -q $target/deploy.zip -d $target
echo "removing deployment archive"
# remove the archive file
rm $target/deploy.zip
echo "switching symbolic link to $target"
# now switch the live site to point to the new release
ln -nsf $target $webroot
echo "done";
fi
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)