Skip to content

Instantly share code, notes, and snippets.

@fridzema
Last active September 11, 2019 09:11
Show Gist options
  • Save fridzema/d1dbc2f1e439fd6f944768ed2822ec0b to your computer and use it in GitHub Desktop.
Save fridzema/d1dbc2f1e439fd6f944768ed2822ec0b to your computer and use it in GitHub Desktop.
Laravel development server deployment script on forge
#!/bin/bash
COMMITMSG=`git log -1 --pretty=%B`
PARALLEL_TASKS=('cache:clear' 'config:cache' 'route:cache' 'view:cache' 'event:cache' 'opcache:compile')
composer install --no-ansi --no-interaction --no-progress --no-dev --prefer-dist --optimize-autoloader --classmap-authoritative -q
php artisan deployment:start
if [[ $COMMITMSG =~ "SYNC" ]]
then
php artisan database:sync -C -M
fi
for task in "${PARALLEL_TASKS[@]}"
do
:
eval "php artisan" ${task} "-q"
done
if [[ $COMMITMSG =~ "MIGRATE" ]]
then
php artisan migrate --force
fi
echo "" | sudo -S service php7.3-fpm reload
php artisan horizon:terminate -q
php artisan deployment:end
echo "🍻"
cd /home/forge/dev.site.com
rm -rf composer.lock
git fetch --depth=1 origin dev
git reset --hard origin/dev
chmod +x deployment-dev.sh
./deployment-dev.sh
@fridzema
Copy link
Author

Takes around 8 seconds on my server for full deploy.
Only downtime is in the php reload command for about, 500ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment