Skip to content

Instantly share code, notes, and snippets.

@harrysbaraini
Created April 9, 2017 19:33
Show Gist options
  • Save harrysbaraini/f82704827e2e1e9dbe311ab1cc8da2c3 to your computer and use it in GitHub Desktop.
Save harrysbaraini/f82704827e2e1e9dbe311ab1cc8da2c3 to your computer and use it in GitHub Desktop.
Git hooks for Laravel
#!/bin/bash
#
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
check_run composer.json "composer install"
check_run package.json "yarn"
check_run bower.json "bower install"
yarn run production
chgrp -R www-data storage bootstrap/cache
chmod -R ug+rwx storage bootstrap/cache
echo "Artisan tasks"
php artisan down
php artisan migrate
php artisan cache:clear
#php artisan config:cache
#php artisan route:cache
php artisan view:clear
php artisan optimize
php artisan storage:link
php artisan up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment