I just started running npm install and npm run production through my Laravel Forge deploy script to compile my assets on the production site. However I noticed that running npm install slows down my deployment by a couple minutes, and I don't think it should need to be run every time I need to push up an update.
Here's my current deploy script:
cd /home/forge/website.com
git pull origin master
npm install
npm run production # Run build process
composer install --no-interaction --prefer-dist --optimize-autoloader
echo "" | sudo -S service php7.2-fpm reload
if [ -f artisan ]
then
php artisan route:clear
php artisan route:cache
php artisan migrate --force
php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan horizon:terminate
fi
Is there a way to check if the package.json file has been changed before running npm install?
Here's something I've tried, but breaks the deploy script and I'm having trouble figuring out why it doesn't work.
cd /home/forge/website.com
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
git pull origin master
check_run package.json "npm install"
npm run production # Run build process
composer install --no-interaction --prefer-dist --optimize-autoloader
echo "" | sudo -S service php7.2-fpm reload
if [ -f artisan ]
then
php artisan route:clear
php artisan route:cache
php artisan migrate --force
php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan horizon:terminate
fi
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire