From 1a7fd964866348eba52ca6a016cb7a7566fd6fd9 Mon Sep 17 00:00:00 2001 From: SysAdmin Date: Mon, 17 Nov 2025 14:02:21 +0000 Subject: [PATCH] fix: Auto-detect Gitea SSH port instead of hardcoding 2223 --- .gitea/workflows/build-and-deploy.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/build-and-deploy.yml b/.gitea/workflows/build-and-deploy.yml index d8776d8..f11ab7f 100644 --- a/.gitea/workflows/build-and-deploy.yml +++ b/.gitea/workflows/build-and-deploy.yml @@ -200,8 +200,22 @@ jobs: eval "$(ssh-agent -s)" ssh-add ~/.ssh/git_deploy_key 2>/dev/null || true + # Try to determine Gitea SSH port (try common ports) + echo "Testing Gitea SSH connectivity..." + for port in 22 2222 2223 3000; do + if nc -z -w1 git.silverlabs.uk $port 2>/dev/null; then + echo "Found SSH service on port $port" + GITEA_SSH_PORT=$port + break + fi + done + + # Default to 22 if not found + GITEA_SSH_PORT=${GITEA_SSH_PORT:-22} + echo "Using SSH port: $GITEA_SSH_PORT" + # Add git.silverlabs.uk to known hosts - ssh-keyscan -p 2223 git.silverlabs.uk >> ~/.ssh/known_hosts 2>/dev/null || true + ssh-keyscan -p $GITEA_SSH_PORT git.silverlabs.uk >> ~/.ssh/known_hosts 2>/dev/null || true # Use home directory for deployment DEPLOY_DIR=~/littleshop @@ -215,10 +229,10 @@ jobs: if [ ! -d .git ]; then echo "Cloning repository via SSH..." rm -rf * # Clean any existing files - GIT_SSH_COMMAND="ssh -i ~/.ssh/git_deploy_key -p 2223" git clone ssh://git@git.silverlabs.uk:2223/Jamie/littleshop.git . + GIT_SSH_COMMAND="ssh -i ~/.ssh/git_deploy_key -p $GITEA_SSH_PORT" git clone ssh://git@git.silverlabs.uk:$GITEA_SSH_PORT/Jamie/littleshop.git . else echo "Repository already cloned, pulling latest..." - GIT_SSH_COMMAND="ssh -i ~/.ssh/git_deploy_key -p 2223" git fetch origin + GIT_SSH_COMMAND="ssh -i ~/.ssh/git_deploy_key -p $GITEA_SSH_PORT" git fetch origin fi echo "Checking out version: $VERSION"