diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 8150d5c..9f286b5 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -16,6 +16,8 @@ set -e DEST="${DEST:-$HOME/toes}" APPS_DIR="${APPS_DIR:-$HOME/apps}" +DATA_DIR="${DATA_DIR:-$HOME/data}" +REPOS_DIR="$DATA_DIR/repos" cd "$DEST" && git checkout -- bun.lock && git pull origin main && bun install && rm -rf dist && bun run build @@ -33,6 +35,29 @@ for app_dir in "$DEST"/apps/*/; do (cd "$target" && bun install --frozen-lockfile 2>/dev/null || bun install) done +echo "=> Initializing bare repos for shipped apps..." +mkdir -p "$REPOS_DIR" +for app_dir in "$DEST"/apps/*/; do + app=$(basename "$app_dir") + [ -f "$app_dir/package.json" ] || continue + bare="$REPOS_DIR/$app.git" + + if [ ! -d "$bare" ]; then + git init --bare "$bare" > /dev/null + git -C "$bare" symbolic-ref HEAD refs/heads/main + git -C "$bare" config http.receivepack true + fi + + tmp=$(mktemp -d) + cp -a "$app_dir"/. "$tmp"/ + git -C "$tmp" init -b main > /dev/null 2>&1 + git -C "$tmp" add -A > /dev/null + git -C "$tmp" -c user.name=toes -c user.email=toes@localhost commit -m "deploy" > /dev/null 2>&1 + git -C "$tmp" push --force "$bare" main > /dev/null 2>&1 + rm -rf "$tmp" + echo " $app" +done + sudo systemctl restart toes.service SCRIPT