Files
EventHubBack/scripts/load-stand-api-env.sh
aleksey 50c6d671b8
CI / test (push) Successful in 14m42s
feat(ci): последовательный deploy IFT -> E2E -> stage -> E2E (core).
Stage после API CT remote на IFT; после stage — smoke-core + полный CT на stage.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-16 11:31:22 +03:00

51 lines
1.3 KiB
Bash
Raw Permalink 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
# Load admin API test credentials from stand .env via SSH into GITHUB_ENV.
# Usage: load-stand-api-env.sh <ift|stage>
set -euo pipefail
STAND="${1:?stand: ift|stage}"
case "${STAND}" in
ift)
SSH_HOST="${SSH_HOST:?IFT_SSH_HOST required}"
SSH_USER="${SSH_USER:?IFT_SSH_USER required}"
SSH_KEY="${SSH_KEY:?IFT_SSH_PRIVATE_KEY required}"
ENV_FILE="/opt/eventhub-ift/.env"
;;
stage)
SSH_HOST="${SSH_HOST:?STAGE_SSH_HOST required}"
SSH_USER="${SSH_USER:?STAGE_SSH_USER required}"
SSH_KEY="${SSH_KEY:?STAGE_SSH_PRIVATE_KEY required}"
ENV_FILE="/opt/eventhub-stage/.env"
;;
*)
echo "Unknown stand: ${STAND}"
exit 1
;;
esac
KEY="$(mktemp)"
printf '%s\n' "${SSH_KEY}" > "${KEY}"
chmod 600 "${KEY}"
REMOTE="$(ssh -i "${KEY}" -o BatchMode=yes -o StrictHostKeyChecking=accept-new \
"${SSH_USER}@${SSH_HOST}" \
"grep -E '^(ADMIN_|SMOKE_ADMIN_)' ${ENV_FILE} || true")"
rm -f "${KEY}"
if [[ -z "${REMOTE}" ]]; then
echo "::error::В ${ENV_FILE} нет ADMIN_* / SMOKE_ADMIN_*"
exit 1
fi
OUT="${GITHUB_ENV:-}"
while IFS= read -r line; do
[[ -n "${line}" ]] || continue
if [[ -n "${OUT}" ]]; then
echo "${line}" >> "${OUT}"
else
printf '%s\n' "${line}" >> "$(mktemp)"
fi
done <<< "${REMOTE}"
echo "Loaded API test credentials from ${ENV_FILE}"