Files
mytodos/deploy.sh
T

47 lines
1.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -euo pipefail
# Update deployment script for mytodos.
# Run from the repository root on the server:
# ./deploy.sh
#
# Pulls the latest code, installs dependencies, runs the new migrations
# (status + position on todos, color on folders), and refreshes the
# admin user via BaseDatabaseSeeder. DatabaseSeeder (demo data) is
# intentionally NOT run in production.
APP_DIR="${APP_DIR:-$(pwd)}"
echo "==> Deploying mytodos update in ${APP_DIR}"
cd "${APP_DIR}"
echo "==> Pulling latest code"
git pull --ff-only origin main
echo "==> Installing PHP dependencies"
composer install --no-dev --prefer-dist --optimize-autoloader
echo "==> Installing and building frontend assets"
if [ -f package-lock.json ]; then
npm ci --no-audit --no-fund
else
npm install --no-audit --no-fund
fi
npm run build
echo "==> Running new migrations"
php artisan migrate --force
echo "==> Seeding base data (admin user)"
php artisan db:seed --class=BaseDatabaseSeeder --force
echo "==> Caching configuration"
php artisan config:cache
php artisan route:cache
php artisan view:cache
echo "==> Restarting queue workers"
php artisan queue:restart
echo "==> Update deployed successfully"