name: Deploy on: push: branches: [main] jobs: deploy: runs-on: self-hosted steps: - name: Checkout run: | if [ ! -d /workspace/darkcodex/api-ubigeo/.git ]; then git clone https://948ee86882f8d9ca46eb94750addfccdace443a6@git.darkcodex.dev/darkcodex/api-ubigeo.git \ /workspace/darkcodex/api-ubigeo fi cd /workspace/darkcodex/api-ubigeo git fetch origin main git reset --hard origin/main - name: Sync source run: | rsync -a --delete \ --exclude='.git' \ --exclude='node_modules' \ --exclude='dist' \ --exclude='.env' \ /workspace/darkcodex/api-ubigeo/ /home/deployer/api-ubigeo/ - name: Build image run: | cd /home/deployer/api-ubigeo docker build -t ubigeo-api:latest . - name: Deploy containers run: | cd /home/deployer/api-ubigeo docker compose -f docker-compose.production.yml down --remove-orphans docker compose -f docker-compose.production.yml up -d - name: Health check run: | sleep 15 STATUS=$(wget -qO- http://127.0.0.1:3200/api/v1/health || echo "fail") echo "Internal health: $STATUS" if echo "$STATUS" | grep -q "ok"; then echo "API is up" else echo "API health check failed" && exit 1 fi