Files
matrix/cinny/dev-update.sh
T
jared 735c1eb30e
Lint / Shell (shellcheck) (push) Has been cancelled
Lint / JS (eslint) (push) Has been cancelled
ci: add lint workflow, shellcheck fixes, and CI failure hookshot alert
- .gitea/workflows/lint.yml: new workflow running shellcheck on .sh files
  and eslint on hookshot/ JS transform scripts
- hookshot/.eslintrc.json: declare data/result as hookshot globals
- hookshot/ci-alert.js: new Matrix hookshot transform for CI failure alerts
- hookshot/deploy.sh: fix SC2155 (split local/assign), SC2034 (remove unused var)
- systemd/livekit-clear-port.sh: fix SC2148 (invalid shebang escape)
- cinny/dev-update.sh: fix SC2115 (use ${WEB_ROOT:?} to guard rm -rf)
- deploy/lxc151-hookshot.sh: add shellcheck source=/dev/null for sourced file
- .gitignore: ignore node_modules/
- package.json + package-lock.json: eslint@8 dev dependency

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 16:25:39 -04:00

60 lines
1.5 KiB
Bash

#!/bin/bash
# Cinny dev branch nightly build and deploy
set -e
REPO_DIR="/opt/cinny-dev"
WEB_ROOT="/var/www/html"
CONFIG_SAVED="/opt/cinny-dev/.cinny-config.json"
BUILD_DIR="/opt/cinny-dev/dist"
LOG="/var/log/cinny-dev-update.log"
exec >> "$LOG" 2>&1
echo "=== $(date) === Starting Cinny dev update ==="
# Save config from live site (skip if web root is already broken)
if [ -f "$WEB_ROOT/config.json" ]; then
cp "$WEB_ROOT/config.json" "$CONFIG_SAVED"
fi
# Pull latest dev
cd "$REPO_DIR"
git fetch --depth=1 origin dev
PREV=$(git rev-parse HEAD)
git reset --hard origin/dev
NEW=$(git rev-parse HEAD)
if [ "$PREV" = "$NEW" ]; then
echo "No changes since last build ($NEW), skipping."
exit 0
fi
echo "New commits since $PREV, building $NEW..."
# Clean previous dist so stale files don't get deployed on partial build
rm -rf "$BUILD_DIR"
# Build — cap at 896MB to stay within 1GB RAM + swap headroom
export NODE_OPTIONS='--max_old_space_size=896'
npm ci 2>&1 | tail -5
npm run build 2>&1 | tail -10
# Verify build actually produced output before touching web root
if [ ! -f "$BUILD_DIR/index.html" ]; then
echo "ERROR: Build failed — dist/index.html missing. Web root untouched."
exit 1
fi
# Deploy only now that we know the build succeeded
rm -rf "${WEB_ROOT:?}"/*
cp -r "$BUILD_DIR"/* "$WEB_ROOT/"
# Restore config
if [ -f "$CONFIG_SAVED" ]; then
cp "$CONFIG_SAVED" "$WEB_ROOT/config.json"
else
echo "WARNING: No saved config found — default config from build will be used."
fi
nginx -s reload
echo "=== Deploy complete: $NEW ==="