Ejemplo de pre-push Git hook para aplicaciones PHP y Docker
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 | |
# Run '$(chmod +x pre-push; ln -s .git/hooks/pre-push pre-push)' to install | |
RESET='\e[0m' | |
RED='\e[31m' | |
GREEN='\e[32m' | |
YELLOW='\e[33m' | |
#---------------------------------------------------------------------------------------------------------------------- | |
# FUNCTIONS | |
#---------------------------------------------------------------------------------------------------------------------- | |
function __displayBox() #(emoji, color, message) | |
{ | |
caption=$(printf "%-72s" "${3}") | |
echo -e "${2}" | |
echo -e "┌─────────────────────────────────────────────────────────────────────────────┐" | |
echo -e "│ ${1} ${RESET}${caption}${2} │" | |
echo -e "└─────────────────────────────────────────────────────────────────────────────┘" | |
echo -e "${RESET}" | |
} | |
#---------------------------------------------------------------------------------------------------------------------- | |
# MAIN LOGIC | |
#---------------------------------------------------------------------------------------------------------------------- | |
if ! make tests; then | |
__displayBox 👹 ${RED} 'GIT PUSH IS NOT ALLOWED!' | |
exit 1 | |
fi | |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
# At this point all checkpoints were successfully passed | |
__displayBox 🚀 ${GREEN} 'GIT PUSH IS ALLOWED!' | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment