From 54f6044e93d988a8bd7f9c461e58e718c445e362 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 26 Mar 2026 22:36:32 +0700 Subject: [PATCH] 690326:2236 Fixing Refactor ADR-019 Naming convention uuid #09 --- .gitea/workflows/ci-deploy.yml | 94 ++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/.gitea/workflows/ci-deploy.yml b/.gitea/workflows/ci-deploy.yml index 161e7ca..bf7b3da 100644 --- a/.gitea/workflows/ci-deploy.yml +++ b/.gitea/workflows/ci-deploy.yml @@ -71,13 +71,59 @@ jobs: - name: ๏ฟฝ Checkout uses: actions/checkout@v4 - - name: ๏ฟฝ Setup SSH and Deploy to QNAP + - name: ๐Ÿ” Setup SSH and Deploy to QNAP run: | # Ensure sshpass is available (install if needed) if ! command -v sshpass &> /dev/null; then apt-get update -qq && apt-get install -y -qq sshpass fi + # Create remote deployment script + REMOTE_SCRIPT=$(cat << 'SCRIPT_EOF' + set -e + export PATH="/share/CACHEDEV1_DATA/.qpkg/container-station/bin:/opt/bin:/usr/local/bin:/usr/bin:/bin:$PATH" + + echo "==========================================" + echo "Starting QNAP Deployment Process" + echo "==========================================" + + # Verify Docker is accessible + if ! docker version > /dev/null 2>&1; then + echo "โœ— Docker not accessible. Check Container Station." + exit 1 + fi + echo "โœ“ Docker accessible" + + # Sync scripts first + echo "๐Ÿ“‚ Syncing deployment scripts..." + cd /share/np-dms/app/source/lcbp3 + + # Check if directory exists + if [ ! -d ".git" ]; then + echo "โœ— Git repository not found at expected path" + exit 1 + fi + + git fetch origin main + git reset --hard origin/main + echo "โœ“ Code synced" + + # Ensure scripts are executable + chmod +x scripts/deploy.sh scripts/rollback.sh 2>/dev/null || true + + mkdir -p /share/np-dms/app/logs + + # Clear Docker build cache to ensure fresh builds + echo "๐Ÿงน Clearing Docker build cache..." + docker builder prune -f || true + + echo "๐Ÿš€ Executing deployment..." + ./scripts/deploy.sh + + echo "โœ“ Deployment completed successfully" + SCRIPT_EOF + ) + # Retry logic for SSH connection max_attempts=3 attempt=1 @@ -85,52 +131,10 @@ jobs: while [ $attempt -le $max_attempts ]; do echo "๐Ÿš€ Deployment attempt $attempt/$max_attempts..." - if sshpass -p "${{ secrets.PASSWORD }}" ssh -o StrictHostKeyChecking=no \ + if echo "$REMOTE_SCRIPT" | sshpass -p "${{ secrets.PASSWORD }}" ssh -o StrictHostKeyChecking=no \ -o ConnectTimeout=30 \ -o ServerAliveInterval=60 \ - -p ${{ secrets.PORT }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} << 'REMOTE_SCRIPT' - set -e - export PATH="/share/CACHEDEV1_DATA/.qpkg/container-station/bin:/opt/bin:/usr/local/bin:/usr/bin:/bin:$PATH" - - echo "==========================================" - echo "Starting QNAP Deployment Process" - echo "==========================================" - - # Verify Docker is accessible - if ! docker version > /dev/null 2>&1; then - echo "โœ— Docker not accessible. Check Container Station." - exit 1 - fi - echo "โœ“ Docker accessible" - - # Sync scripts first - echo "๐Ÿ“‚ Syncing deployment scripts..." - cd /share/np-dms/app/source/lcbp3 - - # Check if directory exists - if [ ! -d ".git" ]; then - echo "โœ— Git repository not found at expected path" - exit 1 - fi - - git fetch origin main - git reset --hard origin/main - echo "โœ“ Code synced" - - # Ensure scripts are executable - chmod +x scripts/deploy.sh scripts/rollback.sh 2>/dev/null || true - - mkdir -p /share/np-dms/app/logs - - # Clear Docker build cache to ensure fresh builds - echo "๐Ÿงน Clearing Docker build cache..." - docker builder prune -f || true - - echo "๐Ÿš€ Executing deployment..." - ./scripts/deploy.sh - - echo "โœ“ Deployment completed successfully" - REMOTE_SCRIPT; then + -p ${{ secrets.PORT }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} 'bash -s'; then echo "โœ… Deployment successful!" exit 0 else