Skip to content

Commit 9c92a80

Browse files
authored
Merge pull request #8 from stack-spot/feat/plan-task
add plan task and handle 304 response
2 parents 95e8622 + 14981af commit 9c92a80

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

runtime-manager-action/script.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,19 @@ def runtime_manager_run_self_hosted_deploy(request_data: dict, manifest: dict):
136136
url=url, body=request_data, headers=HEADERS, timeout=TIMEOUT
137137
)
138138

139-
if response.ok:
140-
# Parse the response and extract relevant data
141-
response_data = response.json()
142-
print(f"> Deploy successfully started:\n{json.dumps(response_data, indent=4)}")
143-
144-
# Save the response to the output log
145-
save_output(response_data)
139+
if response.status_code == 201:
140+
try:
141+
# Parse the response and extract relevant data
142+
response_data = response.json()
143+
print(
144+
f"> Deploy successfully started:\n{json.dumps(response_data, indent=4)}"
145+
)
146+
147+
# Save the response to the output log
148+
save_output(response_data)
149+
except json.JSONDecodeError:
150+
print("> Error: Failed to parse JSON response.")
151+
exit(1)
146152
else:
147153
print(
148154
f"> Error: Failed to start self-hosted deploy run. Status: {response.status_code}"

script.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def run_tasks(file_tasks: str, run_action: RunAction):
5353
IAC_SELF_HOSTED=lambda **i: run_action("runtime-iac-action", **i),
5454
DEPLOY_SELF_HOSTED=lambda **i: run_action("runtime-deploy-action", **i),
5555
DESTROY_SELF_HOSTED=lambda **i: run_action("runtime-destroy-action", **i),
56+
PLAN=lambda **i: run_action("runtime-unified-action", **i),
5657
UNIFIED_IAC=lambda **i: run_action("runtime-unified-action", **i),
5758
UNIFIED_DEPLOY=lambda **i: run_action("runtime-unified-action", **i),
5859
UNIFIED_DESTROY=lambda **i: run_action("runtime-unified-action", **i),
@@ -63,6 +64,8 @@ def run_tasks(file_tasks: str, run_action: RunAction):
6364
runner = task_runners.get(task_type)
6465
if "UNIFIED" in task_type:
6566
runner and runner(run_id=data.get("runId"))
67+
elif "PLAN" == task_type:
68+
runner and runner(run_id=data.get("runId"))
6669
else:
6770
runner and runner(run_task_id=t["runTaskId"])
6871

0 commit comments

Comments
 (0)