Here's what I'm using.  Gitolite and puppet master run on the same box but 
don't have to.  

Note that master is mapped to production.  I also had some issues w/ ssh 
key so the post-receive is starting and killing ssh-agent.  it's not set up 
for pushing multiple branches at the same time but it should be an easy 
change



#!/bin/sh
read oldrev newrev refname

REPO="git@myhost:puppet-environments.git"
BRANCH=`echo $refname | sed -n 's/^refs\/heads\///p'`
BRANCH_DIR="/etc/puppet/environments"
SSH_ARGS="-i /home/git/.ssh/id_rsa"
SSH_DEST="puppet@myhost"

if [ "$BRANCH" == "master" ]
then
   BRANCHDEST="production"
else
   BRANCHDEST=$BRANCH
fi
if [ "$newrev" -eq 0 ] 2> /dev/null ; then
  # branch is being deleted
  echo "Deleting remote branch $BRANCH_DIR/$BRANCHDEST"
  ssh $SSH_ARGS $SSH_DEST /bin/sh <<-EOF
    cd $BRANCH_DIR && rm -rf $BRANCHDEST


EOF
else
  # branch is being updated
  echo "Updating remote branch $BRANCH_DIR/$BRANCHDEST"
  ssh  $SSH_ARGS $SSH_DEST /bin/sh <<-EOF
    { cd $BRANCH_DIR/$BRANCHDEST && git pull origin $BRANCH && ssh-agent 
-k; } \
    || { mkdir -p $BRANCH_DIR && cd $BRANCH_DIR \
         && git clone $REPO $BRANCHDEST && cd $BRANCHDEST \
         && git checkout -b $BRANCH origin/$BRANCH \
         && ssh-agent -k; }
EOF
fi

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/9bf93171-b728-4aeb-ad04-edea7fa7a149%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to