diff --git a/.gitea/workflows/ci-prod.yml b/.gitea/workflows/ci-prod.yml index d77f7c1..0ad69cc 100644 --- a/.gitea/workflows/ci-prod.yml +++ b/.gitea/workflows/ci-prod.yml @@ -130,16 +130,22 @@ jobs: DEST_DIR="/opt/as-talange" RAW_KEY="${PROD_DB_SSH_KEY:-${SSH_KEY_PATH_SECRET:-${SSH_KEY_SECRET}}}" - if [ -z "${RAW_KEY}" ] && [ -f /root/.ssh/gitea_ci_key ]; then - RAW_KEY=$(cat /root/.ssh/gitea_ci_key) - elif [ -z "${RAW_KEY}" ] && [ -f /home/ucef/.ssh/gitea_ci_key ]; then - RAW_KEY=$(cat /home/ucef/.ssh/gitea_ci_key) + 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) + elif [ -f /home/ucef/.ssh/gitea_ci_key ]; then + RAW_KEY=$(cat /home/ucef/.ssh/gitea_ci_key) + fi fi if [ -z "${RAW_KEY}" ]; then echo "=========================================================================" - echo "ERREUR : Le secret PROD_DB_SSH_KEY est vide ou introuvable dans Gitea !" - echo "Veuillez ajouter la clé privée dans Gitea > Dépôt > Paramètres > Secrets > PROD_DB_SSH_KEY" + echo "ERREUR : Le secret PROD_DB_SSH_KEY est vide ou introuvable !" echo "=========================================================================" exit 1 fi @@ -155,11 +161,14 @@ jobs: -e KEY_B64="${KEY_B64}" \ alpine:latest sh -c ' 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 && \ echo "=== 🔍 DIAGNOSTIC DETAILS ===" && \ 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)" && \ 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" && \