#!/bin/bash
export GIT_WORK_TREE=/home/rnb/tester_site #Carpeta publica donde se copian los archivos
export GIT_DIR=/home/rnb/tester.git #Carpeta del repositorio git
while read oldrev newrev ref
do
# only checking out the master (or whatever branch you would like to deploy)
if [[ $ref =~ .*/master$ ]];
then
echo "-------------------------------------------------------------------------->"
echo "--------------------- Actualizando rama MASTER --------------------------->"
echo "-------------------------------------------------------------------------->"
git --work-tree=$GIT_WORK_TREE --git-dir=$GIT_DIR checkout -f
echo " "
echo "-------------------------------------------------------------------------->"
echo "---------------------- Actualizar composer ------------------------------->"
echo "-------------------------------------------------------------------------->"
cd $GIT_WORK_TREE
composer update
composer dump-autoload -o
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done