Added new post-update hook for civicrm-core deployments
authorLisa Marie Maginnis <lisam@fsf.org>
Mon, 6 Oct 2014 19:07:44 +0000 (15:07 -0400)
committerLisa Marie Maginnis <lisam@fsf.org>
Mon, 6 Oct 2014 19:07:44 +0000 (15:07 -0400)
civicrm-core.git/post-update [new file with mode: 0755]

diff --git a/civicrm-core.git/post-update b/civicrm-core.git/post-update
new file mode 100755 (executable)
index 0000000..8411e95
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+unset GIT_DIR
+SELF=civicrm-core.git
+REPO_DIR=$HOME/repositories
+CHECKOUT_DIR=$HOME/local/checkouts/deploy-hooks
+TARGET_DIR=/var/www/html/
+
+case $1 in
+    refs/heads/master)
+       TARGET_HOST=crm.fsf.org
+       branch=master
+       ;;
+    refs/heads/stable)
+       TARGET_HOST=crm-dev.fsf.org
+       branch=stable
+       ;;
+    *)
+       echo "No action for this branch!"
+       ;;
+esac
+
+
+echo "Updating local checkout..."
+if [ ! -d $CHECKOUT_DIR ]; then
+    git clone $REPO_DIR/$SELF $CHECKOUT_DIR
+    git checkout $branch
+    cd $CHECKOUT_DIR
+else
+    cd $CHECKOUT_DIR
+    git checkout $branch
+    git pull origin $branch
+fi
+
+if [ -n TARGET_HOST ]; then
+    echo "Deploying branch '$branch' to host '$TARGET_HOST'"
+
+    echo "Uploading files to $TARGET_HOST web root..."
+    rsync -avrSPX --exclude='.git/' --delete $CHECKOUT_DIR/ 
+       vcshookuser@$TARGET_HOST:$TARGET_DIR
+
+    echo "Fixing permissions on webserver..."
+    ssh vcshookuser@$TARGET_HOST 'sudo /usr/loca/bin/fixperms.sh'
+fi
+
+exec git update-server-info 
+
+