|
6 | 6 | # ./dispatch_internal_repo_workflow.sh \ |
7 | 7 | # --infraRepoName <repo> \ |
8 | 8 | # --releaseVersion <version> \ |
9 | | -# --targetWorkflow "deploy.yaml" \ |
| 9 | +# --targetWorkflow <workflow.yaml> \ |
10 | 10 | # --targetEnvironment <env> \ |
11 | 11 | # --targetComponent <component> \ |
12 | 12 | # --targetAccountGroup <group> \ |
@@ -285,23 +285,16 @@ echo "[INFO] Triggering workflow '$targetWorkflow' in nhs-notify-internal..." |
285 | 285 | echo "[DEBUG] Dispatch event payload: $DISPATCH_EVENT" |
286 | 286 |
|
287 | 287 | trigger_response=$(curl -s -L \ |
288 | | - -w "\nHTTP_STATUS:%{http_code}" \ |
| 288 | + --fail \ |
289 | 289 | -X POST \ |
290 | 290 | -H "Accept: application/vnd.github+json" \ |
291 | 291 | -H "Authorization: Bearer ${PR_TRIGGER_PAT}" \ |
292 | 292 | -H "X-GitHub-Api-Version: 2022-11-28" \ |
293 | 293 | "https://api.github.com/repos/NHSDigital/nhs-notify-internal/actions/workflows/$targetWorkflow/dispatches" \ |
294 | 294 | -d "$DISPATCH_EVENT" 2>&1) |
295 | 295 |
|
296 | | -http_status=$(echo "$trigger_response" | grep "HTTP_STATUS:" | cut -d: -f2) |
297 | | -body=$(echo "$trigger_response" | grep -v "HTTP_STATUS:") |
298 | | - |
299 | | -echo "[DEBUG] HTTP status: $http_status" |
300 | | -echo "[DEBUG] Response body: $body" |
301 | | - |
302 | | -if [[ "$http_status" -lt 200 || "$http_status" -ge 300 ]]; then |
303 | | - echo "[ERROR] Failed to trigger workflow. HTTP $http_status. Response: $body" |
304 | | - exit 1 |
| 296 | +if [[ $? -ne 0 ]]; then |
| 297 | + echo "[ERROR] Failed to trigger workflow. Response: $trigger_response" |
305 | 298 | fi |
306 | 299 |
|
307 | 300 | echo "[INFO] Workflow trigger request sent successfully, waiting for completion..." |
|
0 commit comments