#!/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

composer install |& tee -a $file_name

composer dump-autoload |& tee -a $file_name

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

sudo php artisan migrate |& tee -a $file_name

sudo php artisan optimize:clear |& tee -a $file_name

sudo php artisan optimize |& tee -a $file_name

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

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