fix(ci): handle file paths in RAW_KEY and add key line count diagnostic logs
AS Talange CI/CD Pipeline - Production / Build & Run Unit Tests (push) Successful in 2m9s
AS Talange CI/CD Pipeline - Production / Deploy to Prod Environment (push) Failing after 1m14s

This commit is contained in:
2026-09-03 15:55:13 +02:00
parent a991fd9f35
commit 292c2bb8ec
+14 -5
View File
@@ -130,16 +130,22 @@ jobs:
DEST_DIR="/opt/as-talange" DEST_DIR="/opt/as-talange"
RAW_KEY="${PROD_DB_SSH_KEY:-${SSH_KEY_PATH_SECRET:-${SSH_KEY_SECRET}}}" RAW_KEY="${PROD_DB_SSH_KEY:-${SSH_KEY_PATH_SECRET:-${SSH_KEY_SECRET}}}"
if [ -z "${RAW_KEY}" ] && [ -f /root/.ssh/gitea_ci_key ]; then if [ -n "${RAW_KEY}" ] && [ -f "${RAW_KEY}" ]; then
echo "RAW_KEY is a file path, reading content from: ${RAW_KEY}"
RAW_KEY=$(cat "${RAW_KEY}")
fi
if [ -z "${RAW_KEY}" ]; then
if [ -f /root/.ssh/gitea_ci_key ]; then
RAW_KEY=$(cat /root/.ssh/gitea_ci_key) RAW_KEY=$(cat /root/.ssh/gitea_ci_key)
elif [ -z "${RAW_KEY}" ] && [ -f /home/ucef/.ssh/gitea_ci_key ]; then elif [ -f /home/ucef/.ssh/gitea_ci_key ]; then
RAW_KEY=$(cat /home/ucef/.ssh/gitea_ci_key) RAW_KEY=$(cat /home/ucef/.ssh/gitea_ci_key)
fi fi
fi
if [ -z "${RAW_KEY}" ]; then if [ -z "${RAW_KEY}" ]; then
echo "=========================================================================" echo "========================================================================="
echo "ERREUR : Le secret PROD_DB_SSH_KEY est vide ou introuvable dans Gitea !" echo "ERREUR : Le secret PROD_DB_SSH_KEY est vide ou introuvable !"
echo "Veuillez ajouter la clé privée dans Gitea > Dépôt > Paramètres > Secrets > PROD_DB_SSH_KEY"
echo "=========================================================================" echo "========================================================================="
exit 1 exit 1
fi fi
@@ -155,11 +161,14 @@ jobs:
-e KEY_B64="${KEY_B64}" \ -e KEY_B64="${KEY_B64}" \
alpine:latest sh -c ' alpine:latest sh -c '
apk add --no-cache openssh-client rsync coreutils && \ apk add --no-cache openssh-client rsync coreutils && \
echo "$KEY_B64" | base64 -d > /tmp/working_key && \ (echo "$KEY_B64" | base64 -d 2>/dev/null || echo "$KEY_B64" | base64 --decode) > /tmp/working_key && \
chmod 600 /tmp/working_key && \ chmod 600 /tmp/working_key && \
echo "=== 🔍 DIAGNOSTIC DETAILS ===" && \ echo "=== 🔍 DIAGNOSTIC DETAILS ===" && \
echo "Target Host: ${TARGET_USER}@${TARGET_HOST} (Port: ${PORT})" && \ echo "Target Host: ${TARGET_USER}@${TARGET_HOST} (Port: ${PORT})" && \
echo "Destination Directory: ${DEST_DIR}" && \ 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)" && \
echo "=== 🔑 KEY FINGERPRINT ===" && \ echo "=== 🔑 KEY FINGERPRINT ===" && \
ssh-keygen -l -f /tmp/working_key && \ 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" && \ SSH_CMD="ssh -p ${PORT} -i /tmp/working_key -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=15" && \