Skip to content

Instantly share code, notes, and snippets.

@Sairahcaz
Last active September 23, 2022 07:49
Show Gist options
  • Select an option

  • Save Sairahcaz/ec4e2f19b4c21bf05d8b6cdfe4d266de to your computer and use it in GitHub Desktop.

Select an option

Save Sairahcaz/ec4e2f19b4c21bf05d8b6cdfe4d266de to your computer and use it in GitHub Desktop.
Laravel envy git hook to keep env files up-to-date
#!/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