Skip to content

Instantly share code, notes, and snippets.

@guiliredu
Last active August 27, 2018 12:02
Show Gist options
  • Save guiliredu/91e99f204cf5f5fc2ecc9218ffc02dc5 to your computer and use it in GitHub Desktop.
Save guiliredu/91e99f204cf5f5fc2ecc9218ffc02dc5 to your computer and use it in GitHub Desktop.
Laravel - Deploy scripts
echo '-- Shutdown the laravel app'
php artisan down
echo '-- Pulling from git'
git pull
echo '-- Storage permissions'
#find storage -type f -exec chmod 664 {} \;
#find storage -type d -exec chmod 775 {} \;
echo '-- Install new composer packages'
composer install --no-dev
echo '-- Cache boost configuration and routes'
php artisan cache:clear
php artisan config:cache
php artisan route:cache
echo '-- Sync database changes'
php artisan migrate --force
echo '-- Rise from the ashes'
php artisan up
echo '-- Deploy finished.'
# Shutdown the laravel app
php artisan down
# Install new composer packages
composer install --no-dev --prefer-dist
# Cache boost configuration and routes
php artisan cache:clear
php artisan config:cache
php artisan route:cache
# Sync database changes
php artisan migrate
# Install new node modules
npm install
# Build assets when using Laravel Elixir
#gulp --production
# Build assets when using Laravel Mix
#npm run production
# Rise from the ashes
php artisan up
echo 'Deploy finished.'
# stop script on error signal
set -e
# delete deployment folder if script exit before end last time
if [ -d "/home/forge/deployment" ]; then
rm -R /home/forge/deployment
fi
# set up your env variables if your app using them
export DB_HOST=localhost
export DB_USER=forge
export DB_NAME=forge
export DB_PASS=secretPass
# create new folder for deployment installation
mkdir /home/forge/deployment
cd /home/forge/deployment
# add remote origin to new folder
git init
git remote add origin git@github.com:djuki/djuki.git
# Pull submodules if you have some
git pull origin master
git submodule init
git submodule update
# install dependencies by each workbench and main ones
composer --working-dir=workbench/djuki/aweber install
composer --working-dir=workbench/djuki/multimedia install
composer --working-dir=workbench/djuki/guiders install
composer --working-dir=workbench/djuki/tabledata install
composer install
# Do database migration and seeding
php artisan migrate
php artisan migrate --bench=djuki/multimedia
php artisan migrate --bench=djuki/aweber
php artisan db:seed --class=EmailProviderSeeder
# remove all storage junk
rm -f app/storage/cache/*
rm -f app/storage/views/*
rm -f app/storage/meta/*
# Replace new site wil old one
mv /home/forge/default /home/forge/default-old
mv /home/forge/deployment /home/forge/default
rm -R /home/forge/default-old
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment