Last active
September 23, 2022 07:49
-
-
Save Sairahcaz/ec4e2f19b4c21bf05d8b6cdfe4d266de to your computer and use it in GitHub Desktop.
Laravel envy git hook to keep env files up-to-date
This file contains hidden or 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 | |
| SAIL=vendor/bin/sail | |
| EXECUTOR=$SAIL | |
| SAILCHECK=$($SAIL php -v 2>&1 >/dev/null) | |
| if [[ $SAILCHECK == *"Sail is not running."* ]] || [[ $SAILCHECK == *"Docker is not running."* ]]; then | |
| EXECUTOR=php | |
| fi | |
| #xargs to remove whitespace | |
| CHECK=$($EXECUTOR artisan envy:sync --dry | xargs) | |
| RED='\033[0;31m' | |
| NC='\033[0m' # No Color | |
| if [ "$CHECK" != "There are no variables to sync!" ] | |
| then | |
| printf "${RED}Some env variables are missing, please add them to the specified file before you go on:\n" | |
| printf "$CHECK\n${NC}" | |
| # exit 1 cancels the commit... | |
| exit 1 | |
| fi | |
| # exit 0 continues the commit... | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment