diff --git a/scripts/docker-swarm/deploy.sh b/scripts/docker-swarm/deploy.sh index be2b434..9268dcf 100755 --- a/scripts/docker-swarm/deploy.sh +++ b/scripts/docker-swarm/deploy.sh @@ -305,16 +305,26 @@ if ! $SKIP_CREATE_VMS && ! $DRY_RUN; then fi unset -f local_ssh - REMOTE_REPO="/home/${SSH_USER}/nixos" + # Use PROXMOX_REMOTE_REPO_DIR (from env.sh) so the build path is consistent + # with what create-proxmox-resource.sh will use. The default is + # /home//nixos (the standalone nixos repo clone on pve1), but can be + # overridden to e.g. /home//infrastructure/nixos when the infrastructure + # mono-repo is checked out on pve1 instead. + REMOTE_REPO="${PROXMOX_REMOTE_REPO_DIR:-/home/${SSH_USER}/nixos}" if pve_check "test -d ${REMOTE_REPO}/.git" &>/dev/null; then REMOTE_BRANCH=$(ssh -i ~/.ssh/id_ed25519 "${SSH_USER}@${NODE}" \ "cd ${REMOTE_REPO} && git rev-parse --abbrev-ref HEAD 2>/dev/null") if [[ "$REMOTE_BRANCH" != "$CURRENT_BRANCH" ]]; then - logn "Remote clone is on '${REMOTE_BRANCH}', switching to '${CURRENT_BRANCH}'..." - ssh -i ~/.ssh/id_ed25519 "${SSH_USER}@${NODE}" \ - "cd ${REMOTE_REPO} && git fetch origin && git checkout '${CURRENT_BRANCH}' && git pull --ff-only" - logn "Done." + logn "Remote repo (${REMOTE_REPO}) is on '${REMOTE_BRANCH}', switching to '${CURRENT_BRANCH}'..." + if ssh -i ~/.ssh/id_ed25519 "${SSH_USER}@${NODE}" \ + "cd ${REMOTE_REPO} && git fetch origin && git checkout '${CURRENT_BRANCH}' && git pull --ff-only" 2>&1; then + logn "Done." + else + logn "WARNING: branch switch failed — proceeding anyway (create-proxmox-resource.sh will retry)" + fi fi + else + logn "Remote repo ${REMOTE_REPO} not found on ${NODE} — create-proxmox-resource.sh will clone it." fi fi