Initial commit
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
ssww23
2026-03-10 00:55:37 +03:00
parent fc0f28d830
commit 93a655235a
155 changed files with 24768 additions and 0 deletions

72
scripts/deploy.sh Executable file
View File

@@ -0,0 +1,72 @@
#!/usr/bin/env bash
set -Eeuo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
log() {
printf '\n[%s] %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$1"
}
require_command() {
if ! command -v "$1" >/dev/null 2>&1; then
printf 'Missing required command: %s\n' "$1" >&2
exit 1
fi
}
require_command php
require_command composer
require_command npm
if [[ ! -f artisan ]]; then
printf 'artisan not found in %s\n' "$ROOT_DIR" >&2
exit 1
fi
if [[ ! -f .env ]]; then
printf '.env not found. Create it from .env.example and set production values before deploying.\n' >&2
exit 1
fi
maintenance_enabled=0
deploy_succeeded=0
cleanup() {
if [[ "$maintenance_enabled" -eq 1 && "$deploy_succeeded" -eq 0 ]]; then
printf '\nDeployment failed. The application remains in maintenance mode.\n' >&2
printf 'Fix the issue and run: php artisan up\n' >&2
fi
}
trap cleanup EXIT
log "Putting the application into maintenance mode"
php artisan down --retry=60
maintenance_enabled=1
log "Installing PHP dependencies"
composer install --no-dev --prefer-dist --optimize-autoloader --no-interaction
log "Installing Node.js dependencies"
npm ci
log "Building frontend assets"
npm run build
log "Ensuring the public storage link exists"
php artisan storage:link >/dev/null 2>&1 || true
log "Running Laravel deployment tasks"
composer run deploy --no-interaction
log "Restarting queue workers if they are running"
php artisan queue:restart >/dev/null 2>&1 || true
log "Bringing the application back online"
php artisan up
maintenance_enabled=0
deploy_succeeded=1
log "Deployment completed successfully"

46
scripts/update-from-github.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/usr/bin/env bash
set -Eeuo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
branch="${1:-${DEPLOY_BRANCH:-main}}"
remote="${2:-${DEPLOY_REMOTE:-origin}}"
log() {
printf '\n[%s] %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$1"
}
if ! command -v git >/dev/null 2>&1; then
printf 'Missing required command: git\n' >&2
exit 1
fi
if [[ ! -d .git ]]; then
printf 'No .git directory found in %s\n' "$ROOT_DIR" >&2
printf 'Clone the repository on the server with git before using this script.\n' >&2
exit 1
fi
if ! git diff --quiet || ! git diff --cached --quiet; then
printf 'Tracked local changes detected. Commit or stash them before updating from GitHub.\n' >&2
exit 1
fi
log "Fetching updates from ${remote}"
git fetch --prune "$remote"
if git show-ref --verify --quiet "refs/heads/$branch"; then
log "Switching to branch ${branch}"
git checkout "$branch"
else
log "Creating local branch ${branch} tracking ${remote}/${branch}"
git checkout -b "$branch" --track "${remote}/${branch}"
fi
log "Pulling the latest changes for ${branch}"
git pull --ff-only "$remote" "$branch"
log "Running deployment script"
bash "$ROOT_DIR/scripts/deploy.sh"