Ok here we go.
This works really well on all the sites I implemented it on.
Hopefully it will help you out if you're in a situation where you can't use Envoyer for some reason.
# delete our old deploy directory if it exists
if [ -d "/home/forge/deploy" ]
then
rm -rf /home/forge/deploy
fi
# create a deploy directory
mkdir /home/forge/deploy
# move into the directory
cd /home/forge/deploy
# clone your repository branch
git clone -b $FORGE_SITE_BRANCH [email protected]:Example/example.git .
# copy needed files that aren't committed to git
cp /home/forge/example.com/.env /home/forge/deploy/.env
cp -r /home/forge/example.com/storage /home/forge/deploy
# install dependencies with composer
$FORGE_COMPOSER install --no-interaction --prefer-dist --optimize-autoloader
# restart PHP-FPM
( flock -w 10 9 || exit 1
echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock
# run artisan and node commands
php artisan migrate --force
npm install
npm run production
php artisan config:clear
php artisan cache:clear
php artisan view:clear
php artisan queue:restart
# now that scripts are compiled remove the node directory
rm -rf node_modules
# delete our old backup directory
if [ -d "/home/forge/backup" ]
then
rm -rf /home/forge/backup
fi
# backup the current build
mv /home/forge/example /home/forge/backup
# deploy the new build
mv /home/forge/deploy /home/forge/example.com
# move into new build directory
cd /home/forge/example.com
# link your storage directory
php artisan storage:link
Cheers.