mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
a3579ac57f
- add CODEOWNERS assigning .github/ to @neonsolstice - configure automated updates for npm, docker, and github-actions ecosystems - replace custom change-detection bash script with dorny/paths-filter@v4 - consolidate lint, typecheck, and test into a single checks matrix job - gate per-package change detection via has-changes step (matrix unavailable in job-level if) - fix duplicate actions/setup-node call in setup-node-pnpm composite action - scope pnpm store cache key by pnpm version to prevent stale cross-version cache hits - pin all action references to commit SHAs - fix container-image concurrency group to use commit SHA across all trigger types - add timeout-minutes to all jobs - document fail-fast: false rationale and checks: write trade-off
36 lines
1.1 KiB
Bash
Executable File
36 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
cd "$ROOT_DIR"
|
|
|
|
ENV_FILE="${1:-.env.prod}"
|
|
BACKUP_FILE="${2:-}"
|
|
|
|
if [[ ! -f "$ENV_FILE" ]]; then
|
|
echo "Missing env file: $ENV_FILE" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "$BACKUP_FILE" || ! -f "$BACKUP_FILE" ]]; then
|
|
echo "Usage: $0 <env-file> <backup-file.dump>" >&2
|
|
exit 1
|
|
fi
|
|
|
|
set -a
|
|
# shellcheck disable=SC1090
|
|
source "$ENV_FILE"
|
|
set +a
|
|
|
|
: "${POSTGRES_USER:?POSTGRES_USER is required}"
|
|
: "${POSTGRES_DB:?POSTGRES_DB is required}"
|
|
|
|
docker compose --env-file "$ENV_FILE" -f docker-compose.prod.yml up -d --wait postgres
|
|
docker compose --env-file "$ENV_FILE" -f docker-compose.prod.yml exec -T postgres \
|
|
psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '$POSTGRES_DB' AND pid <> pg_backend_pid();" >/dev/null
|
|
|
|
cat "$BACKUP_FILE" | docker compose --env-file "$ENV_FILE" -f docker-compose.prod.yml exec -T postgres \
|
|
pg_restore -U "$POSTGRES_USER" -d "$POSTGRES_DB" --clean --if-exists --no-owner --no-privileges
|
|
|
|
echo "Restore complete: $BACKUP_FILE -> $POSTGRES_DB"
|