Add git_update.sh and adjust update/test hooks
All checks were successful
CI/CD Pipeline / test (push) Successful in 3s
CI/CD Pipeline / deploy (push) Successful in 23s

This commit is contained in:
2026-02-10 18:38:51 +01:00
parent 30a06e18f0
commit bf278667bc
8 changed files with 186 additions and 180 deletions

47
git_update.sh Normal file
View File

@@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT_DIR"
if [[ -n "$(git status --porcelain)" ]]; then
echo "Working tree is dirty. Please commit or stash changes before updating."
exit 1
fi
echo "Fetching latest refs..."
git fetch --prune --tags
echo "Checking out stable branch..."
git checkout stable
echo "Pulling latest stable..."
git pull --ff-only
echo "Installing PHP dependencies..."
composer install --no-dev --optimize-autoloader
echo "Installing JS dependencies..."
npm install
echo "Building assets..."
npm run build
PHP_BIN="${PHP_BIN:-php}"
echo "Running migrations..."
$PHP_BIN artisan migrate --force
echo "Syncing version/build to settings..."
VERSION="$($PHP_BIN -r '$c=json_decode(file_get_contents("composer.json"), true); echo $c["version"] ?? "";')"
BUILD="$($PHP_BIN -r '$c=json_decode(file_get_contents("composer.json"), true); echo $c["build"] ?? "";')"
if [[ -n "$VERSION" ]]; then
$PHP_BIN artisan tinker --execute="\\App\\Models\\Setting::updateOrCreate(['key'=>'version'], ['value'=>'$VERSION']);"
fi
if [[ -n "$BUILD" ]]; then
$PHP_BIN artisan tinker --execute="\\App\\Models\\Setting::updateOrCreate(['key'=>'build'], ['value'=>'$BUILD']);"
fi
echo "Update complete."