fix(ci): mount /home/ubuntu/.ssh and auto-detect gitea_ci_key location

This commit is contained in:
2026-09-03 14:26:53 +02:00
parent 801fbd359d
commit 2d390b553d
+6 -7
View File
@@ -128,6 +128,7 @@ jobs:
docker run --rm --net=host \
-v "$(pwd):/workspace" -w /workspace \
-v "/home/ubuntu/.ssh:/home/ubuntu/.ssh:ro" \
-v "${HOME}/.ssh:/root/.ssh:ro" \
-e TARGET_HOST="${TARGET_HOST}" \
-e TARGET_USER="${TARGET_USER}" \
@@ -136,13 +137,11 @@ jobs:
alpine:latest sh -c '
apk add --no-cache openssh-client rsync && \
KEY_ARG="" && \
if [ -f /root/.ssh/gitea_ci_key ]; then \
KEY_ARG="-i /root/.ssh/gitea_ci_key -o IdentitiesOnly=yes" ; \
elif [ -f /root/.ssh/id_ed25519 ]; then \
KEY_ARG="-i /root/.ssh/id_ed25519 -o IdentitiesOnly=yes" ; \
elif [ -f /root/.ssh/id_rsa ]; then \
KEY_ARG="-i /root/.ssh/id_rsa -o IdentitiesOnly=yes" ; \
fi && \
for k in /home/ubuntu/.ssh/gitea_ci_key /root/.ssh/gitea_ci_key /home/ubuntu/.ssh/id_ed25519 /root/.ssh/id_ed25519 /home/ubuntu/.ssh/id_rsa /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" && \
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" && \