Kaynağa Gözat

fix(build): paginate artifact resolution in metadata step

resolve_artifact only fetched the first 100 artifacts (per_page=100, no
paging), so on large multi-kernel/multi-root runs the NoMount-Metamodule
artifact fell beyond page 1 and the metadata step failed with
'Expected exactly one available artifact named NoMount-Metamodule'.

Loop over pages until one returns fewer than 100 items, aggregate all
artifacts, then match by name as before.
TheWildJames 2 hafta önce
ebeveyn
işleme
64abd841ff
1 değiştirilmiş dosya ile 19 ekleme ve 5 silme
  1. 19 5
      .github/workflows/build.yml

+ 19 - 5
.github/workflows/build.yml

@@ -582,17 +582,31 @@ jobs:
 
         metadata_file="${{ github.workspace }}/${{ steps.extract.outputs.file_name }}-metadata.json"
         artifacts_api="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts?per_page=100"
-        artifacts_json="$(curl --fail --silent --show-error \
-          --header "Authorization: Bearer ${GH_TOKEN}" \
-          --header "X-GitHub-Api-Version: 2022-11-28" \
-          "$artifacts_api")"
 
         resolve_artifact() {
           local artifact_name="$1"
+          local all_artifacts="[]"
+          local page=1
+          local has_more=true
+
+          while [ "$has_more" = "true" ]; do
+            page_content="$(curl --fail --silent --show-error --location \
+              --header "Authorization: Bearer ${GH_TOKEN}" \
+              --header "X-GitHub-Api-Version: 2022-11-28" \
+              "${artifacts_api}&page=${page}")"
+            all_artifacts="$(jq -cn --argjson acc "$all_artifacts" --argjson cur "$page_content" \
+              '$acc + $cur.artifacts')"
+            items="$(jq '(.artifacts | length) // 0' <<<"$page_content")"
+            if [ "$items" -lt 100 ]; then
+              has_more=false
+            fi
+            page=$((page + 1))
+          done
+
           local matches
           matches="$(jq --arg name "$artifact_name" \
             '[.artifacts[] | select(.name == $name and .expired == false)]' \
-            <<<"$artifacts_json")"
+            <<<"{\"artifacts\": $all_artifacts}")"
           if [ "$(jq 'length' <<<"$matches")" -ne 1 ]; then
             echo "Expected exactly one available artifact named ${artifact_name}." >&2
             exit 1