Forked from rap2hpoutre/laravel-forge-deploy.sh
Last active
April 25, 2023 22:20
Star
You must be signed in to star a gist
Laravel Forge zero downtime deployment script
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
# stop script on error signal | |
set -e | |
SITE="your-site-original-folder-name.com" | |
DEPL="/home/forge/deployments/${SITE}" | |
# create directory and any intermediate directories if don't exist | |
mkdir -p ${DEPL} | |
CUR="/home/forge/${SITE}" | |
NEW="${DEPL}/new" | |
BKP="${DEPL}/backup" | |
# remove old deployment folders | |
if [ -d ${NEW} ]; then | |
rm -R ${NEW} | |
fi | |
if [ -d ${BKP} ]; then | |
rm -R ${BKP} | |
fi | |
cp -R ${CUR} ${NEW} | |
cd ${NEW} | |
# REGULAR SCRIPT (git pull, whatever you do to build assets, reload php clean opcache...) | |
git pull origin develop | |
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev | |
echo "" | sudo -S service php7.1-fpm reload | |
# /REUGLAR SCRIPT | |
# Switch (downtime for microseconds) | |
mv ${CUR} ${BKP} | |
mv ${NEW} ${CUR} |
That's cool! Glad it helped :)
Thanks for this!
Btw; small typo in # /REUGLAR SCRIPT
-> # /REGULAR SCRIPT
Legend mate thank you. Just saved me a few hours!
I would make this one change on the $SITE
variable
SITE=${FORGE_SITE_PATH#"/home/forge/"}
That way, it's fully dynamic and you could copy/paste to a testing/prod environment without changing much.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this, if I make improvements to it I will link a gist here. Handy.