Skip to content

Instantly share code, notes, and snippets.

@AlcidesRC

AlcidesRC/pre-push

Created Mar 12, 2021
Embed
What would you like to do?
Ejemplo de pre-push Git hook para aplicaciones PHP y Docker
#!/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