From c90b379e3187dcdc9db2345bd861ad1d8190b8b3 Mon Sep 17 00:00:00 2001 From: Nikolai Kristiansen Date: Sun, 16 Oct 2011 17:21:31 +0200 Subject: [PATCH] Deploy script with submodules. --- git-deploy-sample2.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 git-deploy-sample2.sh diff --git a/git-deploy-sample2.sh b/git-deploy-sample2.sh new file mode 100755 index 0000000..8cfdf80 --- /dev/null +++ b/git-deploy-sample2.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# Does the following: +# - Clone from bare dir into TMP_DIR +# - Clone submodules +# - Delete .git directories +# - Copy to deploy dir + +DIR="$( cd "$( dirname "$0" )" && pwd )" +REPO_BARE_GIT_DIR="/var/cache/git/repositories/$2" +DEPLOY_DIR=$1 +TMP_DIR="/tmp/git-deploy" +unset GID_DIR +{ + date + git clone $REPO_BARE_GIT_DIR $TMP_DIR + cd $TMP_DIR + if [ -f ".gitmodules" ]; then + git submodule update --init + git submodule foreach 'rm -rf .git/' + fi + rm -rf .git + cp -R $TMP_DIR/* $DEPLOY_DIR + rm -rf $TMP_DIR +} >> "$DIR/deploy.log"