#!/usr/bin/env bash
# Simple zero-downtime-ish update for a single Ubuntu server.
# Usage (as the deploy user, from the project directory): ./docs/deploy/deploy.sh
set -euo pipefail

php artisan down --render="errors::503" --retry=30 || true

git pull --ff-only
composer install --no-dev --optimize-autoloader --no-interaction
npm ci
npm run build

php artisan migrate --force
php artisan db:seed --class=RolesAndPermissionsSeeder --force   # adds permissions for new modules

php artisan storage:link || true
php artisan optimize
php artisan queue:restart
sudo supervisorctl restart drilharob-ssr

php artisan up
echo "Deploy concluído."
