From 2c3ce72a0514f22a1e5d5867102fae9a1b655f83 Mon Sep 17 00:00:00 2001 From: Ming-Yen Chung Date: Fri, 20 Jun 2025 03:02:17 +0800 Subject: [PATCH] KAFKA-18903 update-cache.sh use curl + jq to get sha contains gradle cache instead of gh cli (#19753) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of using the GH CLI (which requires some local setup), we can just use cURL and JQ. Additionally, the original logic required setting up alias.update-cache. After the change, this configuration is no longer necessary. validation on mac: ``` ❯ ./update-cache.sh Local branch 'trunk-cached' successfully updated to f26974b16d (from 19 hours ago). ``` Reviewers: Ken Huang , Chia-Ping Tsai --- committer-tools/update-cache.sh | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/committer-tools/update-cache.sh b/committer-tools/update-cache.sh index 015c2b51d5d..6dbc12e8a1b 100755 --- a/committer-tools/update-cache.sh +++ b/committer-tools/update-cache.sh @@ -16,22 +16,9 @@ # specific language governing permissions and limitations # under the License. -if ! git config --get alias.update-cache > /dev/null; then - printf '\e[36m%s\n\n %s\n\e[0m\n' \ - 'Hint: you can create a Git alias to execute this script. Example:' \ - "git config alias.update-cache '!bash $(realpath "$0")'" -fi - -key="$( - gh cache list \ - --key 'gradle-home-v1|Linux-X64|test' \ - --sort 'created_at' \ - --limit 1 \ - --json 'key' \ - --jq '.[].key' -)" - -sha="$(cut -d '-' -f 5 <<< "$key")" +# Get the latest commit SHA that contains the Gradle build cache. +sha=$(curl -s "https://api.github.com/repos/apache/kafka/actions/caches?key=gradle-home-v1&ref=refs/heads/trunk" \ + | jq -r '.actions_caches | max_by(.created_at) | .key | split("-")[4]') if ! git show "$sha" &> /dev/null; then printf '\e[33m%s\n%s\e[0m\n' \