Skip to content

Commit e63bf71

Browse files
CCM-11942 Updating script with debug info
1 parent 153ab82 commit e63bf71

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

.github/scripts/dispatch_internal_repo_workflow.sh

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ echo " targetComponent: $targetComponent"
102102
echo " targetAccountGroup: $targetAccountGroup"
103103
echo " terraformAction: $terraformAction"
104104
echo " internalRef: $internalRef"
105-
echo "==============================================================="
106105

107106
callerRunId="${GITHUB_RUN_ID}-${jobName}-${GITHUB_RUN_ATTEMPT}"
108107

@@ -150,37 +149,42 @@ echo "[INFO] Workflow trigger request sent successfully, waiting for completion.
150149

151150
# Poll GitHub API to check the workflow status
152151
workflow_run_url=""
152+
153+
WORKFLOW_RUN_EVENT=$(jq -r \
154+
--arg callerRunId "$callerRunId" \
155+
--arg targetWorkflow "$targetWorkflow" \
156+
--arg targetEnvironment "$targetEnvironment" \
157+
--arg targetAccountGroup "$targetAccountGroup" \
158+
--arg targetComponent "$targetComponent" \
159+
--arg terraformAction "$terraformAction" \
160+
'.workflow_runs[]
161+
| select(.path == ".github/workflows/" + $targetWorkflow)
162+
| select(.name
163+
| contains($targetEnvironment)
164+
and contains($targetAccountGroup)
165+
and contains($targetComponent)
166+
and contains($terraformAction)
167+
)
168+
| if ($targetWorkflow | test("dispatch-(acceptance|contextual|product|security)-tests-.*\\.yaml"))
169+
then select(.name | contains("caller:" + $callerRunId))
170+
else .
171+
end
172+
| .url')
173+
174+
echo "[INFO] Checking for workflow run $WORKFLOW_RUN_EVENT"
175+
153176
for _ in {1..18}; do
154-
workflow_run_url=$(curl -s \
177+
workflow_run_url=$(curl -L \
155178
-H "Accept: application/vnd.github+json" \
156179
-H "Authorization: Bearer ${PR_TRIGGER_PAT}" \
157180
-H "X-GitHub-Api-Version: 2022-11-28" \
158181
"https://api.github.com/repos/NHSDigital/nhs-notify-internal/actions/runs?event=workflow_dispatch" \
159-
| jq -r \
160-
--arg callerRunId "$callerRunId" \
161-
--arg targetWorkflow "$targetWorkflow" \
162-
--arg targetEnvironment "$targetEnvironment" \
163-
--arg targetAccountGroup "$targetAccountGroup" \
164-
--arg targetComponent "$targetComponent" \
165-
--arg terraformAction "$terraformAction" \
166-
'.workflow_runs[]
167-
| select(.path == ".github/workflows/" + $targetWorkflow)
168-
| select(.name
169-
| contains($targetEnvironment)
170-
and contains($targetAccountGroup)
171-
and contains($targetComponent)
172-
and contains($terraformAction)
173-
)
174-
| if ($targetWorkflow | test("dispatch-(acceptance|contextual|product|security)-tests-.*\\.yaml"))
175-
then select(.name | contains("caller:" + $callerRunId))
176-
else .
177-
end
178-
| .url')
182+
-d "$WORKFLOW_RUN_EVENT" 2>&1)
179183

180184
if [[ -n "$workflow_run_url" && "$workflow_run_url" != null ]]; then
181185
ui_url=${workflow_run_url/api./}
182186
ui_url=${ui_url/\/repos/}
183-
echo "[INFO] Found workflow run url: $ui_url"
187+
echo "[INFO] Found workflow run url: $ui_url"
184188
break
185189
fi
186190

@@ -191,12 +195,14 @@ done
191195
if [[ -z "$workflow_run_url" || "$workflow_run_url" == null ]]; then
192196
echo "[ERROR] Failed to get the workflow run url. Exiting."
193197
exit 1
198+
else
199+
echo "[INFO] Found workflow run url: $workflow_run_url"
194200
fi
195201

196202
# Wait for workflow completion
197203
while true; do
198204
sleep 10
199-
response=$(curl -s -L \
205+
response=$(curl -L \
200206
-H "Authorization: Bearer ${PR_TRIGGER_PAT}" \
201207
-H "Accept: application/vnd.github+json" \
202208
"$workflow_run_url")

0 commit comments

Comments
 (0)