Last active
January 22, 2023 09:08
-
-
Save philipborbon/a9c82e6aaa8b6830960a04c1ac995db4 to your computer and use it in GitHub Desktop.
Laravel production GIT post-receive
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 | |
TARGET="/home/user/project" | |
GIT_DIR="/home/user/project.git" | |
BRANCH="master" | |
while read oldrev newrev ref | |
do | |
# only checking out the master (or whatever branch you would like to deploy) | |
if [ "$ref" = "refs/heads/$BRANCH" ]; | |
then | |
echo "Ref $ref received. Deploying ${BRANCH} branch to production..." | |
git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH | |
# chmod +x $TARGET/reload.sh | |
php /usr/local/bin/composer install --optimize-autoloader --no-dev --working-dir=$TARGET | |
php $TARGET/artisan config:cache | |
php $TARGET/artisan route:cache | |
php $TARGET/artisan view:cache | |
php $TARGET/artisan queue:restart | |
else | |
echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment