Skip to content

Commit

Permalink
chore: retry fetch dashboard assets (GreptimeTeam#3394)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun authored Feb 27, 2024
1 parent 4b36c28 commit f3d69e9
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions scripts/fetch-dashboard-assets.sh
Original file line number Diff line number Diff line change
@@ -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})
Expand All @@ -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
Expand Down

0 comments on commit f3d69e9

Please sign in to comment.