name: Deploy Development on: push: branches: [develop] workflow_dispatch: jobs: deploy: runs-on: ubuntu-latest steps: - name: Deploy BuyingAgent to development run: | set -e echo "=== Deploying BuyingAgent to DEVELOPMENT ===" REPO="http://192.168.2.144:3000/Lars/BuyingAgent.git" TARGET="/home/lars/docker/buyingagent-dev" mkdir -p "$TARGET" cd "$TARGET" if [ ! -d .git ]; then git clone -b develop "$REPO" . else git fetch origin develop git checkout develop git reset --hard origin/develop fi if [ ! -f .env ]; then printf '%s\n' \ 'DB_NAME=buyingagent_dev' \ 'DB_USER=buyingagent_dev' \ 'DB_PASSWORD=dev_password_change_me' \ 'ENVIRONMENT=development' \ 'BUYING_AGENT_API_PORT=8095' > .env echo "created development .env" fi if grep -q '^BUYING_AGENT_API_PORT=' .env; then sed -i 's/^BUYING_AGENT_API_PORT=.*/BUYING_AGENT_API_PORT=8095/' .env else echo 'BUYING_AGENT_API_PORT=8095' >> .env fi export ENGINE_BUILD BUYING_AGENT_API_PORT ENGINE_BUILD="$(git rev-parse --short HEAD)" BUYING_AGENT_API_PORT=8095 docker compose -f docker-compose.dev-env.yml build --no-cache api if ! ENGINE_BUILD="$ENGINE_BUILD" BUYING_AGENT_API_PORT="$BUYING_AGENT_API_PORT" \ docker compose -f docker-compose.dev-env.yml up -d --wait; then echo "compose up --wait failed — api logs:" docker compose -f docker-compose.dev-env.yml logs api --tail 150 || true docker compose -f docker-compose.dev-env.yml ps || true exit 1 fi if ! curl -sf http://localhost:8095/health/live; then echo "DEV /health/live not reachable — api logs:" docker compose -f docker-compose.dev-env.yml logs api --tail 150 || true exit 1 fi echo "DEV /health/live OK" if ! curl -sf http://localhost:8095/health/ready; then echo "DEV /health/ready failed — api logs:" docker compose -f docker-compose.dev-env.yml logs api --tail 150 || true exit 1 fi echo "DEV /health/ready OK" echo "=== BuyingAgent DEV deploy complete (${ENGINE_BUILD}) ==="