deploy.py: 409 Conflict Handling (POST -> PATCH bei existierenden ENVs)

This commit is contained in:
Agent Zero
2026-08-03 01:32:41 +02:00
parent 7e5e0dd8bd
commit f775405a01
+10 -1
View File
@@ -329,13 +329,22 @@ def deploy_worker(client: CoolifyClient, skip_build: bool = False) -> StepResult
# Step 3: Set ENV variables via Coolify API (Coolify auto-generates .env)
print(" Setting ENV variables via Coolify API...")
for env in WORKER_ENVS:
# POST creates or updates the ENV variable
# POST creates the ENV variable; if it already exists (409),
# PATCH updates it
resp = httpx.post(
f"{client.base_url}/api/v1/services/{WORKER_UUID}/envs",
headers=client.headers,
json=env,
timeout=30,
)
if resp.status_code == 409:
# Already exists — update via PATCH
resp = httpx.patch(
f"{client.base_url}/api/v1/services/{WORKER_UUID}/envs",
headers=client.headers,
json=env,
timeout=30,
)
if resp.status_code not in (200, 201):
print(f" Warning: could not set ENV {env['key']} ({resp.status_code})")