Created
January 30, 2020 10:22
-
-
Save mydnic/d7baff0be20c5bc93b01a2b417156216 to your computer and use it in GitHub Desktop.
Zero Downtime deployment bash script
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
set -e | |
SITE="domain.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 reset --hard HEAD;git clean -df | |
git pull origin master | |
composer install --no-interaction --prefer-dist --optimize-autoloader | |
echo "" | sudo -S service php7.4-fpm reload | |
php artisan migrate --force | |
php artisan queue:restart | |
yarn | |
npm run prod | |
# /REUGLAR SCRIPT | |
# Switch (downtime for microseconds) | |
mv ${CUR} ${BKP} | |
mv ${NEW} ${CUR} | |
cd ${CUR} | |
php artisan cache:clear | |
php artisan config:clear | |
php artisan optimize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment