#!/usr/bin/env bash set -euo pipefail # Deploy BetterBot to RackNerd. REPO_DIR="${REPO_DIR:-/opt/src/betterbot}" STACK_DIR="${STACK_DIR:-/opt/betterbot}" cd "$REPO_DIR" git pull --ff-only origin master mkdir -p "$STACK_DIR" cp compose/docker-compose.yml "$STACK_DIR/docker-compose.yml" # Seed .env from example if it doesn't exist if [ ! -f "$STACK_DIR/.env" ]; then cp compose/.env.example "$STACK_DIR/.env" echo "WARNING: $STACK_DIR/.env created from template — edit it with real secrets." fi # Fetch secrets from Infisical if available if [ -f /opt/config/infisical-agent.env ] && [ -f /opt/src/self_hosting/infra/scripts/infisical-env.sh ]; then source /opt/src/self_hosting/infra/scripts/infisical-env.sh infisical_fetch racknerd-betterbot "$STACK_DIR/.env" fi # Configure git identity for the bot's commits in mounted repos for repo_dir in /opt/src/betterlifesg /opt/src/hk_memoraiz; do if [ -d "$repo_dir/.git" ]; then git -C "$repo_dir" config user.email "betterbot@bytesizeprotip.com" git -C "$repo_dir" config user.name "BetterBot" fi done cd "$STACK_DIR" docker compose build --pull docker compose up -d echo "BetterBot deployed."