使用接收后钩子创建一个zip [英] Using a post-receive hook to create a zip
本文介绍了使用接收后钩子创建一个zip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用钩子已有一段时间了,但是我似乎无法让post-receive
钩子按我需要的方式工作.
I've been playing around with hooks for a while now, but I can't seem to get the post-receive
hook to work the way I need it to.
在将更改推送到存储库后,我试图获取post-receive
钩子来创建一个zip文件夹并将其放置在git存储库文件夹之外的某个位置.
I am trying to get the post-receive
hook to create a zip folder and place it somewhere outside the git repository folders after I have pushed my changes to the repository.
推荐答案
您有一个很好的示例,该示例通过这篇文章. net/>丹尼尔·伯恩:
You have a good example of deploying an zip through a post-receive hook in this article from Daniel Byrne:
想法是使用 git archive --format=zip
:
#!/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
这篇关于使用接收后钩子创建一个zip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文