Merge origin/extended into extended

This commit is contained in:
2026-07-22 13:16:03 +03:00
+65 -3
View File
@@ -59,10 +59,72 @@ jobs:
AUTH_ARGS=(-H "Authorization: token $SAM_GAD")
fi
fetch_all_artifacts() {
local endpoint="$1"
local artifact_name="$2"
local output="$3"
local limit=50
local page=1
local seen=0
local page_json page_count total_count
local items_jsonl="${output}.items.jsonl"
: > "$items_jsonl"
while :; do
page_json="${output}.page-${page}.json"
curl -fsSL "${AUTH_ARGS[@]}" --get \
--data-urlencode "name=${artifact_name}" \
--data-urlencode "limit=${limit}" \
--data-urlencode "page=${page}" \
"$endpoint" \
-o "$page_json"
page_count="$(jq '
def arr:
if type == "array" then .
elif has("artifacts") then .artifacts
elif has("data") then .data
else [] end;
arr | length
' "$page_json")"
jq -c '
def arr:
if type == "array" then .
elif has("artifacts") then .artifacts
elif has("data") then .data
else [] end;
arr[]?
' "$page_json" >> "$items_jsonl"
seen=$((seen + page_count))
total_count="$(jq -r '
if type == "object" then (.total_count // .total // 0)
else 0 end
' "$page_json")"
if [ "$page_count" -eq 0 ]; then
break
fi
if [ "$total_count" -gt 0 ] && [ "$seen" -ge "$total_count" ]; then
break
fi
if [ "$page_count" -lt "$limit" ]; then
break
fi
page=$((page + 1))
done
jq -s '{artifacts: .}' "$items_jsonl" > "$output"
}
artifacts_json="$RUNNER_TEMP/rr-wrt-artifacts.json"
curl -fsSL "${AUTH_ARGS[@]}" \
"${API_BASE}/artifacts?name=${RR_ARTIFACT_NAME}&per_page=100&page=1" \
-o "$artifacts_json"
fetch_all_artifacts \
"${API_BASE}/artifacts" \
"$RR_ARTIFACT_NAME" \
"$artifacts_json"
jq -r '
def arr: