From 606faeda2a6a947c3f5fd94dd368eeba56796010 Mon Sep 17 00:00:00 2001 From: Iszuddin Ismail Date: Wed, 13 May 2026 12:24:56 +0800 Subject: [PATCH] fixing test and deploy script --- .gitea/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 07ef380..52f6c74 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -75,18 +75,43 @@ jobs: - name: Build frontend assets run: npm run build + - name: Upload deployment artifact + uses: actions/upload-artifact@v3.2.2-node20 + with: + name: laravel-build + path: | + app + bootstrap + config + database + public + resources + routes + vendor + artisan + composer.json + package.json + vite.config.js + if-no-files-found: error + deploy: name: Deploy runs-on: ubuntu-latest needs: build steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Download build artifact + uses: actions/download-artifact@v3-node20 + with: + name: laravel-build + path: release - name: Install sshpass run: sudo apt-get update && sudo apt-get install -y sshpass + - name: Install rsync + run: sudo apt-get install -y rsync + - name: Add SSH host to known_hosts env: DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} @@ -117,14 +142,11 @@ jobs: rsync -az --delete \ -e "sshpass -e ssh -p ${DEPLOY_PORT:-22}" \ --exclude='.env' \ - --exclude='.git' \ --exclude='storage/logs/*' \ --exclude='storage/framework/cache/*' \ --exclude='storage/framework/sessions/*' \ --exclude='storage/framework/views/*' \ - --exclude='vendor' \ - --exclude='node_modules' \ - . "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}" + release/ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}" - name: Create .env on server from secret env: @@ -148,7 +170,7 @@ jobs: printf '%s' "$DEPLOY_ENV_FILE" | sshpass -e ssh -p "${DEPLOY_PORT:-22}" "${DEPLOY_USER}@${DEPLOY_HOST}" "mkdir -p \"${DEPLOY_PATH}\" && cat > \"${DEPLOY_PATH}/.env\" && chmod 600 \"${DEPLOY_PATH}/.env\"" - - name: Install dependencies and build on server + - name: Run post-deploy Laravel commands env: DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }} @@ -162,7 +184,7 @@ jobs: exit 1 fi - sshpass -e ssh -p "${DEPLOY_PORT:-22}" "${DEPLOY_USER}@${DEPLOY_HOST}" "cd ${DEPLOY_PATH} && composer install --no-dev --optimize-autoloader && npm ci && npm run build && php artisan optimize:clear && php artisan config:cache && php artisan route:cache && php artisan view:cache" + sshpass -e ssh -p "${DEPLOY_PORT:-22}" "${DEPLOY_USER}@${DEPLOY_HOST}" "cd ${DEPLOY_PATH} && php artisan optimize:clear && php artisan config:cache && php artisan route:cache && php artisan view:cache" # Required repository secrets: # - DEPLOY_HOST: Server hostname or IP.