fix(ci): validate SSH key header format and provide explicit guidance for Gitea secret value

This commit is contained in:
2026-09-04 07:04:21 +02:00
parent 37611dc79f
commit dae97f15ba
+18 -4
View File
@@ -131,7 +131,7 @@ jobs:
RAW_KEY="${PROD_DB_SSH_KEY:-${SSH_KEY_PATH_SECRET:-${SSH_KEY_SECRET}}}"
if [ -n "${RAW_KEY}" ] && [ -f "${RAW_KEY}" ]; then
echo "RAW_KEY is a file path, reading content from: ${RAW_KEY}"
echo "RAW_KEY is a readable file path on host, reading content..."
RAW_KEY=$(cat "${RAW_KEY}")
fi
@@ -145,7 +145,7 @@ jobs:
if [ -z "${RAW_KEY}" ]; then
echo "========================================================================="
echo "ERREUR : Le secret PROD_DB_SSH_KEY est vide ou introuvable !"
echo "ERREUR : Le secret PROD_DB_SSH_KEY est totalement vide dans Gitea !"
echo "========================================================================="
exit 1
fi
@@ -167,8 +167,22 @@ jobs:
echo "Target Host: ${TARGET_USER}@${TARGET_HOST} (Port: ${PORT})" && \
echo "Destination Directory: ${DEST_DIR}" && \
echo "Key File Line Count: $(wc -l < /tmp/working_key)" && \
echo "Key File First Line: $(head -n 1 /tmp/working_key)" && \
echo "Key File Last Line: $(tail -n 1 /tmp/working_key)" && \
HEADER=$(head -n 1 /tmp/working_key) && \
echo "Key File First Line: $HEADER" && \
case "$HEADER" in \
*"BEGIN"*) \
echo "--> Key header format is VALID" ;; \
*) \
echo "=========================================================================" && \
echo "ERREUR CONFIGURATION SECRET GITEA :" && \
echo "Le secret PROD_DB_SSH_KEY ne contient pas le texte d une clé SSH !" && \
echo "Valeur actuelle reçue dans le secret : $HEADER" && \
echo "CONSEIL : Dans Gitea > Paramètres > Secrets > PROD_DB_SSH_KEY, tu dois coller" && \
echo "le CONTENU TEXTUEL complet de la clé (ex: cat /root/.ssh/gitea_ci_key)" && \
echo "et NON PAS un chemin comme /root/.ssh/..." && \
echo "=========================================================================" && \
exit 1 ;; \
esac && \
echo "=== 🔑 KEY FINGERPRINT ===" && \
ssh-keygen -l -f /tmp/working_key && \
SSH_CMD="ssh -p ${PORT} -i /tmp/working_key -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=15" && \