From 484aa3fecee2d133446c7f888abedf3e44b048a6 Mon Sep 17 00:00:00 2001 From: "Kalana B. Thilakarathna" Date: Sun, 20 Sep 2026 16:02:53 +0530 Subject: [PATCH] Update appsettings.json URLs and add CI/CD workflow for ERP Distribution --- .gitea/workflows/ci-cd.yml | 85 +++++++++++++++++++++++++++++++++++ Distribution/appsettings.json | 4 +- 2 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/ci-cd.yml diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml new file mode 100644 index 0000000..cfd7e5d --- /dev/null +++ b/.gitea/workflows/ci-cd.yml @@ -0,0 +1,85 @@ +name: CI/CD - ERP Distribution +on: + pull_request: + branches: + - production + types: + - closed +jobs: + build-and-deploy-backend: + name: Build & Deploy Backend + runs-on: linux + if: github.event.pull_request.merged == true + steps: + - name: Checkout code + run: | + git clone \ + --depth 1 \ + --branch production \ + https://oauth2:${{ secrets.DISTRIBUTION }}@gitea.hexdive.com/New_REP_SYSTEM/ERP_Distribution.git \ + . + - name: Restore + run: dotnet restore Distribution/Distribution.csproj + - name: Publish + run: | + rm -rf /tmp/erpdistribution-deploy + mkdir -p /tmp/erpdistribution-deploy + dotnet publish Distribution/Distribution.csproj \ + -c Release \ + -r linux-x64 \ + --self-contained true \ + -o /tmp/erpdistribution-deploy + - name: Stop service + run: systemctl stop erpdistribution.service + - name: Copy to deploy folder + run: | + mkdir -p /home/distribution/core/publish + rm -rf /home/distribution/core/publish/* + cp -r /tmp/erpdistribution-deploy/* /home/distribution/core/publish/ + - name: Fix ownership and permissions + run: | + chown -R distributionuser:distributionuser /home/distribution/core/publish + find /home/distribution/core/publish -type d -exec chmod 755 {} + + find /home/distribution/core/publish -type f -exec chmod 644 {} + + chmod +x /home/distribution/core/publish/Distribution + - name: Restart service + run: systemctl restart erpdistribution.service + - name: Verify + run: | + systemctl is-active erpdistribution.service && echo "✅ Service running" || echo "❌ Service failed" + + build-and-deploy-frontend: + name: Build & Deploy Frontend + runs-on: linux + if: github.event.pull_request.merged == true + steps: + - name: Checkout code + run: | + git clone \ + --depth 1 \ + --branch production \ + https://oauth2:${{ secrets.DISTRIBUTION_FE }}@gitea.hexdive.com/New_REP_SYSTEM/ERP_Distribution_FE.git \ + . + - name: Build Docker image + run: docker build -t erpdistributionfe:latest . + - name: Stop & remove existing container + run: | + docker stop erpdistributionfe 2>/dev/null || true + docker rm erpdistributionfe 2>/dev/null || true + - name: Start container + run: | + docker run -d \ + --name erpdistributionfe \ + -p 8801:3000 \ + --restart unless-stopped \ + --memory="512m" \ + --cpus="1.0" \ + --cap-drop ALL \ + --security-opt no-new-privileges \ + erpdistributionfe:latest + - name: Remove old images + run: docker image prune -f + - name: Verify + run: | + docker ps --filter name=erpdistributionfe --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" \ + | grep erpdistributionfe && echo "✅ Container running" || echo "❌ Container failed" diff --git a/Distribution/appsettings.json b/Distribution/appsettings.json index d63b6f9..f2b1778 100644 --- a/Distribution/appsettings.json +++ b/Distribution/appsettings.json @@ -1,5 +1,5 @@ { - "Urls": "http://localhost:5089", + "Urls": "http://localhost:8802", "ConnectionStrings": { "DefaultConnection": "Server=187.127.102.190;Port=3306;Database=distribution;User=kalana;Password=kalana@hexdive" }, @@ -21,7 +21,7 @@ }, "AuthHex": { - "BaseUrl": "http://localhost:6102" + "BaseUrl": "http://localhost:8801" }, "StoreManagement": { "UnverifiedKycOrderThreshold": 0