Last active
January 22, 2021 18:42
-
-
Save fahmilatib/82ce5414350a85585d209c3b3f8acaa4 to your computer and use it in GitHub Desktop.
Git post-receive hook
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/sh | |
git_dir=$(pwd) | |
production_dir=<path> | |
artisan() { php artisan $1; } | |
cd "$production_dir" | |
# Begin maintenance mode | |
artisan 'down --retry=60' | |
cd "$git_dir" | |
# Checkout latest version and remove untracked files | |
git --work-tree=$production_dir checkout -f | |
git --work-tree=$production_dir clean -df | |
cd "$production_dir" | |
# Refresh PHP dependencies | |
composer install --no-dev | |
# Optimize Laravel | |
artisan cache:clear | |
artisan config:cache | |
artisan route:cache | |
artisan view:clear | |
# Recompile assets | |
yarn && yarn run production | |
# End maintenance mode | |
artisan up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment