From 6d4d1e2abd3f54d47c473be3806a96039e68eb22 Mon Sep 17 00:00:00 2001 From: skulidropek <66840575+skulidropek@users.noreply.github.com> Date: Mon, 23 Mar 2026 05:53:40 +0000 Subject: [PATCH] ci: derive telegram bot username during api deploy --- scripts/deploy-prod.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/deploy-prod.sh b/scripts/deploy-prod.sh index 3946a94..9a1f60f 100644 --- a/scripts/deploy-prod.sh +++ b/scripts/deploy-prod.sh @@ -2,7 +2,7 @@ set -euo pipefail if [[ $# -lt 2 ]]; then - echo "Usage: $0 [ssh-host] [ssh-user] [telegram-bot-username] [mini-app-short-name] [public-origin]" >&2 + echo "Usage: $0 [ssh-host] [ssh-user] [public-origin]" >&2 exit 1 fi @@ -10,18 +10,24 @@ SSH_PASSWORD="$1" TELEGRAM_BOT_TOKEN="$2" SSH_HOST="${3-spawn-dock.w3voice.net}" SSH_USER="${4:-ops}" -TELEGRAM_BOT_USERNAME="${5-TMASpawnerBot}" -TELEGRAM_MINI_APP_SHORT_NAME="${6-tma}" -PUBLIC_ORIGIN="${7:-https://spawn-dock.w3voice.net}" +PUBLIC_ORIGIN="${5:-https://spawn-dock.w3voice.net}" TARGET_DIR="/srv/spawndock-api" BOT_SECRET="$(openssl rand -hex 24)" BOT_CONTROL_PLANE_URL="http://mcp-server:3000" PUBLIC_HOST=":80" +TELEGRAM_MINI_APP_SHORT_NAME="tma" if [[ "$PUBLIC_ORIGIN" =~ ^https://([^/]+)$ ]]; then PUBLIC_HOST="${BASH_REMATCH[1]}" fi +TELEGRAM_BOT_USERNAME="$( + curl -fsS "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/getMe" \ + | python3 -c 'import json, sys; data = json.load(sys.stdin); result = data.get("result") or {}; username = result.get("username"); +if not data.get("ok") or not username: raise SystemExit("Could not resolve Telegram bot username from token"); +print(username, end="")' +)" + ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" TMP_ARCHIVE="$(mktemp /tmp/spawndock-api.XXXXXX.tar.gz)" TMP_ENV="$(mktemp /tmp/spawndock-api.env.XXXXXX)"