From c57a894d7a9d0da51fa4465cdef2211eedb60188 Mon Sep 17 00:00:00 2001 From: Simo Date: Sat, 11 Jul 2026 23:01:53 +0200 Subject: [PATCH] Update .gitea/workflows/deploy.yaml --- .gitea/workflows/deploy.yaml | 91 ++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 29 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index d7ea4331..fe6632cc 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -1,4 +1,5 @@ name: Remote Build and Deploy + on: push: branches: @@ -7,49 +8,81 @@ on: jobs: deploy: runs-on: ubuntu-latest + steps: - - name: Deploying via SSH connection to VPS Host + - name: Check out pushed commit + uses: actions/checkout@v4 + + - name: Create release archive + run: | + set -Eeuo pipefail + git archive \ + --format=tar.gz \ + --output=atomcms-release.tar.gz \ + "${GITHUB_SHA:-HEAD}" + + - name: Upload release to VPS + uses: appleboy/scp-action@v0.1.7 + with: + host: "172.20.2.1" + username: "root" + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: 22 + source: "atomcms-release.tar.gz" + target: "/tmp" + overwrite: true + + - name: Install and deploy on VPS uses: appleboy/ssh-action@v1.0.3 with: host: "172.20.2.1" username: "root" key: ${{ secrets.SSH_PRIVATE_KEY }} port: 22 + command_timeout: 20m script: | + set -Eeuo pipefail + + readonly APP_DIR="/var/www/atom-nexst" + readonly RELEASE="/tmp/atomcms-release.tar.gz" + echo "--- Starting EPIC WEB CONTROL Deployment ---" - - # 1. Navigate to your project directory on the VPS - cd /var/www/atom-nexst/ - - # 2. Synchronize the application files via Git - git fetch origin - git reset --hard origin/main - - # --- CLEAN-UP STEP --- - echo "--- Moving or removing specific items ---" - # rm -rf /var/www/atom-nexst/directory-name - - # Install missing node_modules based on updated package.json - echo "--- Installing Dependencies ---" - pnpm install --frozen-lockfile - # Load environment variables from .env file for the next steps - export $(grep -v '^#' .env | xargs) + test -d "$APP_DIR" + test -f "$APP_DIR/.env" + test -f "$RELEASE" + + cd "$APP_DIR" + test "$PWD" = "$APP_DIR" + + echo "--- Updating Application Files ---" + + # Preserve .env, storage and node_modules. + # Remove source directories so deleted files cannot remain on VPS. + rm -rf -- src public prisma scripts + + tar -xzf "$RELEASE" -C "$APP_DIR" + rm -f -- "$RELEASE" + + echo "--- Preparing pnpm ---" + corepack enable + corepack prepare pnpm@10.33.4 --activate + + echo "--- Installing Locked Dependencies ---" + pnpm install --frozen-lockfile --prod=false + + echo "--- Generating Prisma Client ---" + pnpm prisma:generate - # 3. Run database migrations natively echo "--- Running Database Migrations ---" pnpm db:migrate - - # Regenerate Prisma Client to update types (Fixes userWatch error) - echo "--- Generating Prisma Client Types ---" - pnpm prisma generate - - # 4. Compile the updated distribution assets + echo "--- Building Application ---" + rm -rf -- .next pnpm build - - # 5. Restart the host background service cleanly + echo "--- Restarting Atom Nexst Service ---" - sudo systemctl restart atom-nexst.service - + systemctl restart atom-nexst.service + systemctl is-active --quiet atom-nexst.service + echo "--- Deployment Completed Successfully ---" \ No newline at end of file