Last active
January 18, 2021 10:26
-
-
Save goidor/80c4606c75137a8bdc50 to your computer and use it in GitHub Desktop.
Hook de Ejemplo para hacer deploy de aplicación en producción o en desarrollo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### El script debe estar en la ruta .git/hooks/post-receive del servidor Git | |
while read oldrev newrev ref | |
do | |
if [[ $ref =~ .*/master$ ]]; then | |
echo "Push a $ref recibido. Procesando despliegue de rama $ref en Producción...." | |
git --work-tree=/srv/http/html --git-dir=/home/goidor/git/proyecto.git checkout -f master | |
elif [[ $ref =~ .*/develop$ ]]; then | |
echo "Push a $ref recibido. Procesando despliegue de rama $ref en Desarrollo...." | |
git --work-tree=/srv/http/html-develop --git-dir=/home/goidor/git/proyecto.git checkout -f develop | |
else | |
echo "Push de $ref recibido. No se hace nada, solo las ramas master y develop pueden hacer despliegue." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment