3

post-receiveしばらくフックをいじっていますが、フックを必要なように機能させることができないようです。

post-receive変更をリポジトリにプッシュした後、フックを取得して zip フォルダを作成し、それを git リポジトリ フォルダの外に配置しようとしています。

4

1 に答える 1

7

Daniel Byrneのこの記事には、post-receive フックを介して zip を展開する良い例があります。

アイデアは使用すること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
于 2012-12-19T06:58:50.447 に答える