#!/bin/bash
#deploy project

mkdir -p deploy_log
file_name=deploy_log/deploy_$(date "+%Y_%m_%d_%H_%M_%S")

echo 'Deployment Started . . . . .' |& tee $file_name

chmod -R 777 storage/
chmod -R 777 bootstrap/cache/

git reset --hard

git pull origin development |& tee -a $file_name

npm install |& tee -a $file_name

npm run dev |& tee -a $file_name

/opt/cpanel/ea-php80/root/bin/php /opt/cpanel/composer/bin/composer install |& tee -a $file_name

/opt/cpanel/ea-php80/root/bin/php /opt/cpanel/composer/bin/composer dump-autoload |& tee -a $file_name

chmod -R 777 storage/
chmod -R 777 bootstrap/cache/

/opt/cpanel/ea-php80/root/bin/php artisan migrate |& tee -a $file_name

/opt/cpanel/ea-php80/root/bin/php artisan optimize:clear |& tee -a $file_name

chmod -R 777 storage/
chmod -R 777 bootstrap/cache/

echo 'Deploy finished . . . !' |& tee -a $file_name