From edffa1f249d19bf3ed89a014c209531a6bd89008 Mon Sep 17 00:00:00 2001 From: SysAdmin Date: Mon, 17 Nov 2025 13:40:06 +0000 Subject: [PATCH] fix: Use tilde expansion and escape variables for remote execution --- .gitea/workflows/build-and-deploy.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/build-and-deploy.yml b/.gitea/workflows/build-and-deploy.yml index b962a50..0f94cf5 100644 --- a/.gitea/workflows/build-and-deploy.yml +++ b/.gitea/workflows/build-and-deploy.yml @@ -187,41 +187,40 @@ jobs: - name: Deploy to CT109 run: | - export GITEA_TOKEN="${{ secrets.SECRET }}" ssh -i ~/.ssh/deploy_key -p ${{ secrets.CT109_SSH_PORT }} ${{ secrets.CT109_USER }}@${{ secrets.CT109_HOST }} bash -s << ENDSSH set -e export VERSION="${{ github.sha }}" - export GITEA_TOKEN="$GITEA_TOKEN" + export GITEA_TOKEN="${{ secrets.SECRET }}" # Use home directory for deployment - DEPLOY_DIR="$HOME/littleshop" - echo "Using deployment directory: $DEPLOY_DIR" + DEPLOY_DIR=~/littleshop + echo "Using deployment directory: \$DEPLOY_DIR" # Create deployment directory if it doesn't exist - mkdir -p "$DEPLOY_DIR" - cd "$DEPLOY_DIR" + mkdir -p "\$DEPLOY_DIR" + cd "\$DEPLOY_DIR" # Clone or pull latest code if [ ! -d .git ]; then echo "Cloning repository with authentication..." rm -rf * # Clean any existing files - git clone https://oauth2:${GITEA_TOKEN}@git.silverlabs.uk/Jamie/littleshop.git . + git clone https://oauth2:\${GITEA_TOKEN}@git.silverlabs.uk/Jamie/littleshop.git . else echo "Repository already cloned, pulling latest..." git fetch origin fi - echo "Checking out version: $VERSION" - git checkout $VERSION || git checkout main + echo "Checking out version: \$VERSION" + git checkout \$VERSION || git checkout main # Build images on CT109 echo "Building LittleShop image..." - docker build --no-cache -t littleshop:$VERSION . - docker tag littleshop:$VERSION littleshop:latest + docker build --no-cache -t littleshop:\$VERSION . + docker tag littleshop:\$VERSION littleshop:latest echo "Building TeleBot image..." - docker build --no-cache -t telebot:$VERSION -f Dockerfile.telebot . - docker tag telebot:$VERSION telebot:latest + docker build --no-cache -t telebot:\$VERSION -f Dockerfile.telebot . + docker tag telebot:\$VERSION telebot:latest # Stop existing containers echo "Stopping existing containers..."