Files
gitea-review-bot/docker-entrypoint.sh
T
Keysat e5a187b507 Walk the default branch first, and keep ssh noise out of the room
Rooms mapped before the push watch existed carry no default_branch, so
the "report a commit as being on master, not on some stale branch that
also contains it" ordering never applied to them. Look it up once and
keep it.

known_hosts lives in the image, so it resets on every rebuild and the
first ssh connection printed "Permanently added ... to the list of known
hosts" straight into the room, prepended to the first assessment. Set
LogLevel ERROR in the generated ssh config; real errors still come back.

Corrects two claims in Current state that the API contradicts: the repo
has had three PRs, not zero, and their review threads for #2 and #3 are
orphaned in the room right now.
2026-08-21 10:49:55 -05:00

35 lines
1.1 KiB
Bash

#!/bin/sh
# gitea-review-bot container entrypoint — the container's "environment seam".
#
# Generates ~/.ssh/config for the Mac alias from config.toml's [mac] section, then execs the bot.
# SSH-client wiring lives here, not in bot.py (same split matrix-bridge uses). On the Spark host the
# bot would use modelo's existing ~/.ssh/config; in the container we recreate just the one alias.
set -e
SSH_DIR="$HOME/.ssh"
mkdir -p "$SSH_DIR"
chmod 700 "$SSH_DIR"
GRB_SSH_KEY="${GRB_SSH_KEY:-$SSH_DIR/id_ed25519}" \
SSH_CONFIG="$SSH_DIR/config" \
KNOWN_HOSTS="$SSH_DIR/known_hosts" \
python - <<'PY'
import os, tomllib
with open("/app/config.toml", "rb") as f:
mac = tomllib.load(f)["mac"]
config = f"""Host {mac.get('ssh_alias', 'mac-bridge')}
HostName {mac['hostname']}
User {mac['user']}
IdentityFile {os.environ['GRB_SSH_KEY']}
IdentitiesOnly yes
StrictHostKeyChecking accept-new
UserKnownHostsFile {os.environ['KNOWN_HOSTS']}
LogLevel ERROR
"""
with open(os.environ['SSH_CONFIG'], "w") as f:
f.write(config)
PY
chmod 600 "$SSH_DIR/config"
exec "$@"