Created
January 21, 2021 00:08
-
-
Save kevinarrieta/70abade326c0a777e653d3d3e8279d8e to your computer and use it in GitHub Desktop.
Git post-receive hook sample for Laravel deployment
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/sh | |
# The production directory | |
TARGET="/var/www/{domain}/html/{project}/" # trailing slash matters | |
# A temporary directory for deployment | |
TEMP="/var/www/{domain}/tmp/{project}/" # trailing slash matters | |
# The Git repo | |
REPO="/var/www/{domain}/git/{project}.git" | |
# Deploy the content to the temporary directory | |
mkdir -p $TEMP | |
git --work-tree=$TEMP --git-dir=$REPO checkout -f | |
cd $TEMP | |
# deployment tasks | |
# update PHP dependencies | |
composer install --no-interaction --no-dev --prefer-dist | |
# --no-interaction Do not ask any interactive question | |
# --no-dev Disables installation of require-dev packages. | |
# --prefer-dist Forces installation from package dist even for dev versions. | |
# update database | |
# php artisan migrate --force | |
# misc | |
# Replace the production directory | |
# with the temporary directory | |
cd / | |
# rm -rf $TARGET | |
# mv -fT $TEMP $TARGET | |
rsync -rlptD $TEMP $TARGET | |
rm -rf $TEMP | |
cd $TARGET | |
php artisan migrate --force | |
php artisan queue:restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment