Skip to content

Commit 1a7bebd

Browse files
committed
fix: missing workflow id
1 parent a30eae0 commit 1a7bebd

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

entrypoint.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,18 @@ get_workflow_runs() {
123123

124124
echo "Getting workflow runs using query: ${query}" >&2
125125

126-
api "workflows/${INPUT_WORKFLOW_FILE_NAME}/runs?${query}" |
127-
jq -r '.workflow_runs[].id' |
126+
response=$(api "workflows/${INPUT_WORKFLOW_FILE_NAME}/runs?${query}")
127+
128+
# Validate response is valid JSON with workflow_runs array
129+
if ! echo "$response" | jq -e '.workflow_runs' > /dev/null 2>&1; then
130+
echo "Error: Invalid API response or missing workflow_runs" >&2
131+
echo "Response: $response" >&2
132+
return 1
133+
fi
134+
135+
echo "$response" |
136+
jq -r '.workflow_runs[].id | select(. != null) | tostring' |
137+
grep -E '^[0-9]+$' |
128138
sort # Sort to ensure repeatable order, and lexicographically for compatibility with join
129139
}
130140

0 commit comments

Comments
 (0)