fix(ci): mount /home/ubuntu/.ssh and auto-detect gitea_ci_key location
This commit is contained in:
@@ -128,6 +128,7 @@ jobs:
|
|||||||
|
|
||||||
docker run --rm --net=host \
|
docker run --rm --net=host \
|
||||||
-v "$(pwd):/workspace" -w /workspace \
|
-v "$(pwd):/workspace" -w /workspace \
|
||||||
|
-v "/home/ubuntu/.ssh:/home/ubuntu/.ssh:ro" \
|
||||||
-v "${HOME}/.ssh:/root/.ssh:ro" \
|
-v "${HOME}/.ssh:/root/.ssh:ro" \
|
||||||
-e TARGET_HOST="${TARGET_HOST}" \
|
-e TARGET_HOST="${TARGET_HOST}" \
|
||||||
-e TARGET_USER="${TARGET_USER}" \
|
-e TARGET_USER="${TARGET_USER}" \
|
||||||
@@ -136,13 +137,11 @@ jobs:
|
|||||||
alpine:latest sh -c '
|
alpine:latest sh -c '
|
||||||
apk add --no-cache openssh-client rsync && \
|
apk add --no-cache openssh-client rsync && \
|
||||||
KEY_ARG="" && \
|
KEY_ARG="" && \
|
||||||
if [ -f /root/.ssh/gitea_ci_key ]; then \
|
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 \
|
||||||
KEY_ARG="-i /root/.ssh/gitea_ci_key -o IdentitiesOnly=yes" ; \
|
if [ -f "$k" ]; then \
|
||||||
elif [ -f /root/.ssh/id_ed25519 ]; then \
|
KEY_ARG="-i $k -o IdentitiesOnly=yes" && break ; \
|
||||||
KEY_ARG="-i /root/.ssh/id_ed25519 -o IdentitiesOnly=yes" ; \
|
fi ; \
|
||||||
elif [ -f /root/.ssh/id_rsa ]; then \
|
done && \
|
||||||
KEY_ARG="-i /root/.ssh/id_rsa -o IdentitiesOnly=yes" ; \
|
|
||||||
fi && \
|
|
||||||
SSH_CMD="ssh -p ${PORT} ${KEY_ARG} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=15" && \
|
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})..." && \
|
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" && \
|
$SSH_CMD "${TARGET_USER}@${TARGET_HOST}" "mkdir -p ${DEST_DIR}/scripts" && \
|
||||||
|
|||||||
Reference in New Issue
Block a user