Skip to content

Instantly share code, notes, and snippets.

@cyppst
Forked from triswan/deploy-laravel-2.sh
Created June 1, 2020 16:07
Show Gist options
  • Save cyppst/dd26a53464389f9b47644bcd6aeb6dd8 to your computer and use it in GitHub Desktop.
Save cyppst/dd26a53464389f9b47644bcd6aeb6dd8 to your computer and use it in GitHub Desktop.
Laravel Deployment
#!/bin/sh
#
## store the arguments given to the script
read oldrev newrev refname
## Where to store the log information about the updates
LOGFILE=./post-receive.log
# The deployed directory (the running site)
DEPLOYDIR=/home/swamedia/source/portal-elogistics
## Record the fact that the push has been received
echo -e "Received Push Request at $( date +%F )" >> $LOGFILE
echo " - Old SHA: $oldrev New SHA: $newrev Branch Name: $refname" >> $LOGFILE
## Update the deployed copy
echo "Starting Deployment" >> $LOGFILE
echo " - Starting code update"
GIT_WORK_TREE="$DEPLOYDIR" git checkout -f
echo " - Finished code update"
echo " - Starting dependencies install & build"
cd "$DEPLOYDIR"
/home/swamedia/opt/bin/composer install --no-ansi --no-interaction --no-progress --no-scripts --optimize-autoloader
/home/swamedia/opt/node-v6.11.4-linux-x64/bin/npm run dev
cd -
echo " - Finished dependencies install & build"
echo " - Starting laravel optimization"
cd "$DEPLOYDIR"
#php artisan clear-compiled
php artisan cache:clear
php artisan view:clear
php artisan config:cache
php artisan route:cache
php artisan optimize
php artisan migrate
cd -
echo " - Finished laravel optimization"
echo "Finished Deployment" >> $LOGFILE
# Install application dependencies, such as the Laravel framework itself.
#
# If you run composer update in development and commit the `composer.lock`
# file to your repository, then `composer install` will install the exact
# same versions in production.
composer install --no-interaction
# npm run prod
php artisan clear:view
php artisan route:cache
php artisan config:cache
php artisan storage:link
# Clear the old boostrap/cache/compiled.php
php artisan clear-compiled
# Recreate boostrap/cache/compiled.php
php artisan optimize
# Migrate any database changes
php artisan migrate
git reset --hard
git pull origin develop
composer install
cp .env.example .env
php artisan key:generate
php artisan migrate --seed
php artisan cache:clear
php artisan config:clear
php artisan storage:link
sudo chown -R erp:www-data /var/www/app/amlo2/
find /var/www/app/amlo2/ -type f -exec chmod 664 {} \;
find /var/www/app/amlo2/ -type d -exec chmod 775 {} \;
chgrp -R www-data storage bootstrap/cache
chmod -R ug+rwx storage bootstrap/cache
rsync -avz app/Repositories/ swaarief@192.168.5.41://home/swaarief/source/portal-elogistics/app/Repositories/
rsync -avz resources/ swaarief@192.168.5.41://home/swaarief/source/portal-elogistics/resources/
rsync -avz app/ swaarief@192.168.5.42://home/swaarief/source/portal-elogistics/app/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment