Skip to content

Instantly share code, notes, and snippets.

@defenestrator
Forked from tonioriol/laravel-forge-deploy.sh
Last active April 22, 2021 18:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save defenestrator/71ab86a058582b8492a6727d3e3f4be2 to your computer and use it in GitHub Desktop.
Laravel Forge zero downtime deployment script
# stop script on error signal
set -e
SITE="example.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 previous deployment folders
if [ -d ${NEW} ]; then
rm -R ${NEW}
fi
if [ -d ${BKP} ]; then
rm -R ${BKP}
fi
cp -R ${CUR} ${NEW}
cd ${NEW}
#####################################################################
# Insert the rest of your standard Forge deployment script below here
#####################################################################
#####################################################################
# Your standard Forge deployment should end above, or at least before
# the switch, seriously. You're entering a world of pain, otherwise.
#####################################################################
# Switch (this will cause microseconds of downtime)
mv ${CUR} ${BKP}
mv ${NEW} ${CUR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment