From 2584ab8715e9861d5f0e3a61759c7069b2aa04f6 Mon Sep 17 00:00:00 2001 From: kalana_Thilakarathna Date: Sun, 20 Sep 2026 11:34:29 +0000 Subject: [PATCH] Update .gitea/workflows/ci-cd.yml --- .gitea/workflows/ci-cd.yml | 65 +++++++++++++++----------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml index a5809dc..7bb569f 100644 --- a/.gitea/workflows/ci-cd.yml +++ b/.gitea/workflows/ci-cd.yml @@ -1,4 +1,3 @@ -# test name: CI/CD - ERP Core Monorepo on: @@ -9,8 +8,8 @@ on: - closed jobs: - backend-build-and-deploy: - name: Build & Deploy ERP Core Backend + build-and-deploy-backend: + name: Build & Deploy Backend runs-on: linux if: github.event.pull_request.merged == true steps: @@ -21,68 +20,58 @@ jobs: --branch production \ https://oauth2:${{ secrets.ERPCORE }}@gitea.hexdive.com/New_REP_SYSTEM/ERP-core.git \ . - - - name: Restore backend - working-directory: .gitea/workflows - run: dotnet restore ../../Backend/ERPCore.sln - - - name: Publish backend - working-directory: .gitea/workflows + - name: Restore + run: dotnet restore Backend/ERPCore.sln + - name: Publish run: | rm -rf /tmp/erpcore-deploy mkdir -p /tmp/erpcore-deploy - dotnet publish ../../Backend/ERPCore/ERPCore.csproj \ + dotnet publish Backend/ERPCore/ERPCore.csproj \ -c Release \ -r linux-x64 \ --self-contained true \ -o /tmp/erpcore-deploy - - - name: Stop backend service + - name: Stop service run: systemctl stop erpcore.service - - - name: Copy backend to deploy folder + - name: Copy to deploy folder run: | mkdir -p /home/erp/core/publish rm -rf /home/erp/core/publish/* cp -r /tmp/erpcore-deploy/* /home/erp/core/publish/ - - - name: Fix backend ownership and permissions + - name: Fix ownership and permissions run: | chown -R erpuser:erpuser /home/erp/core/publish find /home/erp/core/publish -type d -exec chmod 755 {} + find /home/erp/core/publish -type f -exec chmod 644 {} + chmod +x /home/erp/core/publish/ERPCore - - - name: Restart backend service + - name: Restart service run: systemctl restart erpcore.service - - - name: Verify backend + - name: Verify run: | - systemctl is-active erpcore.service && echo "Backend service running" || echo "Backend service failed" + systemctl is-active erpcore.service && echo "✅ Service running" || echo "❌ Service failed" - frontend-build-and-deploy: - name: Build & Deploy ERP Core Frontend + build-and-deploy-frontend: + name: Build & Deploy Frontend runs-on: linux if: github.event.pull_request.merged == true steps: - name: Checkout code run: | - rm -rf /tmp/erpcore-frontend-src git clone \ --depth 1 \ - --branch production \ + --branch Production \ https://oauth2:${{ secrets.ERPCORE }}@gitea.hexdive.com/New_REP_SYSTEM/ERP-core.git \ - /tmp/erpcore-frontend-src - - - name: Build frontend Docker image - run: docker build -t erpcore-frontend:latest /tmp/erpcore-frontend-src/Frontend/erp-system - - - name: Stop & remove existing frontend container + . + - name: Build Docker image + run: | + docker build --progress=plain --no-cache \ + -t erpcore-frontend:latest \ + ./Frontend/erp-system + - name: Stop & remove existing container run: | docker stop erpcore-frontend 2>/dev/null || true docker rm erpcore-frontend 2>/dev/null || true - - - name: Start frontend container + - name: Start container run: | docker run -d \ --name erpcore-frontend \ @@ -95,11 +84,9 @@ jobs: --cap-drop ALL \ --security-opt no-new-privileges \ erpcore-frontend:latest - - - name: Remove old frontend images + - name: Remove old images run: docker image prune -f - - - name: Verify frontend + - name: Verify run: | docker ps --filter name=erpcore-frontend --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" \ - | grep erpcore-frontend && echo "Frontend container running" || echo "Frontend container failed" + | grep erpcore-frontend && echo "✅ Container running" || echo "❌ Container failed" -- 2.52.0