From f3d69e9563afedfb0bff1929ac7b8a595cf128d1 Mon Sep 17 00:00:00 2001 From: tison Date: Tue, 27 Feb 2024 18:07:21 +0800 Subject: [PATCH] chore: retry fetch dashboard assets (#3394) Signed-off-by: tison --- scripts/fetch-dashboard-assets.sh | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/scripts/fetch-dashboard-assets.sh b/scripts/fetch-dashboard-assets.sh index 357980cd30..9ffc10b7df 100755 --- a/scripts/fetch-dashboard-assets.sh +++ b/scripts/fetch-dashboard-assets.sh @@ -1,8 +1,7 @@ #!/usr/bin/env bash # This script is used to download built dashboard assets from the "GreptimeTeam/dashboard" repository. - -set -e -x +set -ex declare -r SCRIPT_DIR=$(cd $(dirname ${0}) >/dev/null 2>&1 && pwd) declare -r ROOT_DIR=$(dirname ${SCRIPT_DIR}) @@ -20,13 +19,32 @@ else GITHUB_URL="${GITHUB_PROXY_URL%/}" fi +function retry_fetch() { + local url=$1 + local filename=$2 + + curl \ + --connect-timeout 10 \ + --retry 3 \ + --retry-connrefused \ + -fsSL $url --output $filename || \ + { + echo "Failed to download $url" + echo "You may try to set http_proxy and https_proxy environment variables." + if [[ -z "$GITHUB_PROXY_URL" ]]; then + echo "You may try to set GITHUB_PROXY_URL=http://mirror.ghproxy.com/" + fi + exit 1 + } +} + # Download the SHA256 checksum attached to the release. To verify the integrity # of the download, this checksum will be used to check the download tar file # containing the built dashboard assets. -curl -Ls ${GITHUB_URL}/GreptimeTeam/dashboard/releases/download/$RELEASE_VERSION/sha256.txt --output sha256.txt +retry_fetch "${GITHUB_URL}/GreptimeTeam/dashboard/releases/download/${RELEASE_VERSION}/sha256.txt" sha256.txt # Download the tar file containing the built dashboard assets. -curl -L ${GITHUB_URL}/GreptimeTeam/dashboard/releases/download/$RELEASE_VERSION/build.tar.gz --output build.tar.gz +retry_fetch "${GITHUB_URL}/GreptimeTeam/dashboard/releases/download/$RELEASE_VERSION/build.tar.gz" build.tar.gz # Verify the checksums match; exit if they don't. case "$(uname -s)" in