From 0e15269e99e3d32c4bac0256f7bc89275cd49490 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Wed, 27 Nov 2024 19:50:02 +0000 Subject: [PATCH] Fix INSTALL_K3S_PR support Filter check names server-side instead of with jq. With recent changes to CI we now have more than 30 check runs, which is more than the API will return by default. Rather than paginating or increasing the page size, ask the server to filter for us. Also replaces the awk/sort/head with jq split/sort/last Signed-off-by: Brad Davidson --- install.sh | 10 ++-------- install.sh.sha256sum | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index b55d2fd4114e..a6a7fd201f92 100755 --- a/install.sh +++ b/install.sh @@ -512,16 +512,10 @@ get_pr_artifact_url() { fi # GET request to the GitHub API to retrieve the Build workflow associated with the commit - wf_raw=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "${github_api_url}/commits/${commit_id}/check-runs") - build_workflow=$(printf "%s" "${wf_raw}" | jq -r '.check_runs[] | select(.name == "build / Build")') + run_id=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "${github_api_url}/commits/${commit_id}/check-runs?check_name=build%20%2F%20Build" | jq -r '[.check_runs | sort_by(.id) | .[].details_url | split("/")[7]] | last') - # Extract the Run ID from the build workflow and lookup artifacts associated with the run - run_id=$(echo "${build_workflow}" | jq -r ' .details_url' | awk -F'/' '{print $(NF-2)}' | sort -rn | head -1) - # Extract the artifact ID for the "k3s" artifact - artifacts=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "${github_api_url}/actions/runs/${run_id}/artifacts") - artifacts_url=$(echo "${artifacts}" | jq -r '.artifacts[] | select(.name == "k3s") | .archive_download_url') - GITHUB_PR_URL="${artifacts_url}" + GITHUB_PR_URL=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "${github_api_url}/actions/runs/${run_id}/artifacts" | jq -r '.artifacts[] | select(.name == "k3s") | .archive_download_url') } # --- download binary from github url --- diff --git a/install.sh.sha256sum b/install.sh.sha256sum index 7d2ffb48ec6a..a55937101827 100644 --- a/install.sh.sha256sum +++ b/install.sh.sha256sum @@ -1 +1 @@ -f49035378daf603b0dbd458efb4d50608d3499aab3b2e724384dfb5801153669 install.sh +d75e014f2d2ab5d30a318efa5c326f3b0b7596f194afcff90fa7a7a91166d5f7 install.sh