From f48532f2d04ab13b2b6e9ab28961e83f81c52c03 Mon Sep 17 00:00:00 2001 From: Simo Date: Sat, 11 Jul 2026 23:05:14 +0200 Subject: [PATCH] Update .gitea/workflows/deploy.yaml Signed-off-by: Simo --- .gitea/workflows/deploy.yaml | 105 ++++++++++++++++------------------- 1 file changed, 48 insertions(+), 57 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index fe6632cc..3a6a71f5 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -5,84 +5,75 @@ on: branches: - main +concurrency: + group: atomcms-production-deploy + cancel-in-progress: false + jobs: deploy: - runs-on: ubuntu-latest + runs-on: shell steps: - name: Check out pushed commit uses: actions/checkout@v4 + with: + fetch-depth: 1 - - name: Create release archive + - name: Deploy AtomCMS + shell: bash 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 + readonly APP_DIR="/var/www/atom-nexst" + readonly SOURCE_DIR="${GITHUB_WORKSPACE}" - - 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 + echo "--- Starting EPIC WEB CONTROL Deployment ---" - readonly APP_DIR="/var/www/atom-nexst" - readonly RELEASE="/tmp/atomcms-release.tar.gz" + test -n "$SOURCE_DIR" + test -d "$SOURCE_DIR/src" + test -f "$SOURCE_DIR/package.json" + test -f "$SOURCE_DIR/pnpm-lock.yaml" - echo "--- Starting EPIC WEB CONTROL Deployment ---" + test -d "$APP_DIR" + test -f "$APP_DIR/.env" + test "$APP_DIR" = "/var/www/atom-nexst" - test -d "$APP_DIR" - test -f "$APP_DIR/.env" - test -f "$RELEASE" + echo "--- Synchronizing Application Files ---" - cd "$APP_DIR" - test "$PWD" = "$APP_DIR" + sudo rsync -a --delete \ + --exclude=".git/" \ + --exclude=".env" \ + --exclude=".next/" \ + --exclude="node_modules/" \ + --exclude="storage/" \ + --exclude="docs/" \ + "$SOURCE_DIR/" "$APP_DIR/" - echo "--- Updating Application Files ---" + cd "$APP_DIR" + test "$PWD" = "$APP_DIR" - # Preserve .env, storage and node_modules. - # Remove source directories so deleted files cannot remain on VPS. - rm -rf -- src public prisma scripts + echo "--- Preparing pnpm ---" + sudo corepack enable + sudo corepack prepare pnpm@10.33.4 --activate - tar -xzf "$RELEASE" -C "$APP_DIR" - rm -f -- "$RELEASE" + echo "--- Installing Locked Dependencies ---" + sudo pnpm install --frozen-lockfile --prod=false - echo "--- Preparing pnpm ---" - corepack enable - corepack prepare pnpm@10.33.4 --activate + echo "--- Generating Prisma Client ---" + sudo pnpm prisma:generate - echo "--- Installing Locked Dependencies ---" - pnpm install --frozen-lockfile --prod=false + echo "--- Running Database Migrations ---" + sudo pnpm db:migrate - echo "--- Generating Prisma Client ---" - pnpm prisma:generate + echo "--- Building Application ---" + sudo rm -rf -- "$APP_DIR/.next" + sudo pnpm build - echo "--- Running Database Migrations ---" - pnpm db:migrate + echo "--- Restarting Atom Nexst Service ---" + sudo systemctl restart atom-nexst.service + sudo systemctl is-active --quiet atom-nexst.service - echo "--- Building Application ---" - rm -rf -- .next - pnpm build + echo "--- Verifying Deployed Revision ---" + echo "DEPLOYED_COMMIT=${GITHUB_SHA}" - echo "--- Restarting 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 + echo "--- Deployment Completed Successfully ---" \ No newline at end of file