name: CI/CD - ERP Ledger on: pull_request: branches: - production types: - closed jobs: build-and-deploy: name: Build & Deploy runs-on: linux if: github.event.pull_request.merged == true steps: - name: Checkout code run: | git clone \ --depth 1 \ --branch production \ https://oauth2:${{ secrets.ERPLedger }}@gitea.hexdive.com/Hexdive-Internal-Services/General-Ledger-Service.git \ . - name: Restore run: dotnet restore General-Ledgar-Service.csproj - name: Publish run: | rm -rf /tmp/erpl-edger-deploy mkdir -p /tmp/erpl-edger-deploy dotnet publish General-Ledgar-Service.csproj \ -c Release \ -r linux-x64 \ --self-contained true \ -o /tmp/erpl-edger-deploy - name: Stop service run: systemctl stop erpLedger.service - name: Copy to deploy folder run: | rm -rf /var/www/internalServices/generalLedger/publish/* cp -r /tmp/erpl-edger-deploy/* /var/www/internalServices/generalLedger/publish/ - name: Fix ownership and permissions run: | chown -R ledgeruser:ledgeruser /var/www/internalServices/generalLedger/publish find /var/www/internalServices/generalLedger/publish/ -type d -exec chmod 755 {} + find /var/www/internalServices/generalLedger/publish -type f -exec chmod 644 {} + chmod +x /var/www/internalServices/generalLedger/publish/General-Ledgar-Service - name: Restart service run: systemctl restart erpLedger.service - name: Verify run: | systemctl is-active erpLedger.service && echo "✅ Service running" || echo "❌ Service failed"