Files
social-post-writer-bot/.hermes/scripts/deploy.sh
T

51 lines
1.8 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Деплой приложения в Coolify v4 (ставит деплой в очередь).
# Coolify API не имеет endpoint /applications/{uuid}/deploy —
# деплой запускается через POST /api/v1/deploy?uuid=<app-uuid>&force=false
#
# Использование:
# ./deploy.sh # деплой по умолчанию (social-post-writer-bot-development)
# APP_UUID=<uuid> ./deploy.sh # деплой другого приложения
# APP_UUID=<uuid> FORCE=true ./deploy.sh
set -euo pipefail
# Универсально: uuid можно переопределить через env
APP_UUID="${APP_UUID:-d32u5zcq2g4odmdpq9hw91yn}"
APP_NAME="${APP_NAME:-social-post-writer-bot-development}"
FORCE="${FORCE:-false}"
COOLIFY_API="${COOLIFY_API:-http://10.19.0.2:8000/api/v1}"
COOLIFY_TOKEN=$(grep '^COOLIFY_TOKEN=' /root/.hermes/.env | cut -d= -f2-)
log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"; }
if [ -z "$COOLIFY_TOKEN" ]; then
echo "ERROR: COOLIFY_TOKEN не найден в /root/.hermes/.env" >&2
exit 1
fi
log "Запуск деплоя $APP_NAME (uuid=$APP_UUID, force=$FORCE)"
RESP=$(curl -sS --max-time 60 -X POST \
-H "Authorization: Bearer ${COOLIFY_TOKEN}" \
-H "Content-Type: application/json" \
"${COOLIFY_API}/deploy?uuid=${APP_UUID}&force=${FORCE}")
echo "$RESP"
# Проверяем, что деплой поставлен в очередь
if printf '%s' "$RESP" | grep -q '"deployment_uuid"'; then
DEPLOY_UUID=$(printf '%s' "$RESP" | python3 -c '
import json,sys
try:
d=json.load(sys.stdin)
print(d["deployments"][0]["deployment_uuid"])
except Exception:
print("")')
log "DEPLOY В ОЧЕРЕДИ: $DEPLOY_UUID"
exit 0
else
echo "ERROR: деплой не запустился" >&2
exit 1
fi