From c5e3fdd9157238e70a784550a357d11be0a010d4 Mon Sep 17 00:00:00 2001 From: arifal Date: Tue, 4 Mar 2025 15:05:13 +0700 Subject: [PATCH] create file automation deployment using sh --- deploy.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 deploy.sh diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..0c7b0f0 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,38 @@ +GIT_BRANCH="dev" +PHP_VERSION="php8.3" + +echo "🚀 Starting deployment..." +php artisan down + +echo "📥 Pulling latest changes from Git..." +git fetch origin $GIT_BRANCH +git reset --hard origin/$GIT_BRANCH +git pull origin $GIT_BRANCH + +echo "⚡ Installing NPM dependencies and building assets..." +npm ci --no-audit --no-fund +npm run build + +echo "📦 Installing composer dependencies..." +composer install --no-interaction --optimize-autoloader + +echo "🗄️ Running migrations..." +php artisan migrate --force + +echo "⚡ Optimizing application..." +php artisan cache:clear +php artisan config:clear +php artisan config:cache +php artisan route:cache +php artisan view:cache + +echo "🔄 Restarting PHP service..." +systemctl restart $PHP_VERSION-fpm + +echo "🔁 Restarting Supervisor queue workers..." +supervisorctl stop all +supervisorctl reload +supervisorctl start all + +php artisan up +echo "🚀 Deployment completed successfully!" \ No newline at end of file