diff --git a/.gitea/workflows/build-and-deploy.yml b/.gitea/workflows/build-and-deploy.yml index aa15b83..babb3f7 100644 --- a/.gitea/workflows/build-and-deploy.yml +++ b/.gitea/workflows/build-and-deploy.yml @@ -191,16 +191,25 @@ jobs: set -e export VERSION="${{ github.sha }}" - # Navigate to deployment directory - cd /opt/littleshop || mkdir -p /opt/littleshop && cd /opt/littleshop + # Use home directory for deployment + DEPLOY_DIR="$HOME/littleshop" + echo "Using deployment directory: $DEPLOY_DIR" + + # Create deployment directory if it doesn't exist + mkdir -p "$DEPLOY_DIR" + cd "$DEPLOY_DIR" # Clone or pull latest code if [ ! -d .git ]; then echo "Cloning repository..." + rm -rf * # Clean any existing files git clone https://git.silverlabs.uk/Jamie/littleshop.git . + else + echo "Repository already cloned, pulling latest..." + git fetch origin fi - echo "Pulling latest code from git..." - git fetch origin + + echo "Checking out version: $VERSION" git checkout $VERSION || git checkout main # Build images on CT109