refactor(ci): simplify SSH step to directly copy and use /root/.ssh/gitea_ci_key with 600 permissions
AS Talange CI/CD Pipeline - Production / Build & Run Unit Tests (push) Successful in 2m8s
AS Talange CI/CD Pipeline - Production / Deploy to Prod Environment (push) Failing after 1m14s

This commit is contained in:
2026-09-03 14:40:45 +02:00
parent 2472407cca
commit 747cf1a0fa
+4 -8
View File
@@ -129,20 +129,16 @@ jobs:
docker run --rm --net=host \
-v "$(pwd):/workspace" -w /workspace \
-v "/root/.ssh:/root/.ssh:ro" \
-v "/home/ubuntu/.ssh:/home/ubuntu/.ssh:ro" \
-e TARGET_HOST="${TARGET_HOST}" \
-e TARGET_USER="${TARGET_USER}" \
-e PORT="${PORT}" \
-e DEST_DIR="${DEST_DIR}" \
alpine:latest sh -c '
apk add --no-cache openssh-client rsync && \
KEY_ARG="" && \
for k in /root/.ssh/gitea_ci_key /home/ubuntu/.ssh/gitea_ci_key /root/.ssh/id_ed25519 /root/.ssh/id_rsa; do \
if [ -f "$k" ]; then \
KEY_ARG="-i $k -o IdentitiesOnly=yes" && break ; \
fi ; \
done && \
SSH_CMD="ssh -p ${PORT} ${KEY_ARG} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=15" && \
mkdir -p ~/.ssh && \
cp /root/.ssh/gitea_ci_key ~/.ssh/id_rsa && \
chmod 600 ~/.ssh/id_rsa && \
SSH_CMD="ssh -p ${PORT} -i ~/.ssh/id_rsa -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=15" && \
echo "Deploying backup script and .env to DB Server (${TARGET_USER}@${TARGET_HOST}:${DEST_DIR})..." && \
$SSH_CMD "${TARGET_USER}@${TARGET_HOST}" "mkdir -p ${DEST_DIR}/scripts" && \
rsync -avz -e "$SSH_CMD" scripts/backup_db.sh "${TARGET_USER}@${TARGET_HOST}:${DEST_DIR}/scripts/" && \