Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add retry logic in the Install Go Tip GitHub Action #5022

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 35 additions & 13 deletions .github/actions/setup-go-tip/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,38 @@ runs:
shell: bash
run: |
set -euo pipefail
tip=$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}')
echo "Go Tip version: ${tip}"
curl -fsSL https://storage.googleapis.com/go-build-snap/go/linux-amd64/${tip}.tar.gz -o gotip.tar.gz
echo "Downloaded bundle:"
ls -lah gotip.tar.gz
export GOROOT="$HOME/sdk/gotip"
mkdir -p $GOROOT
tar -C $GOROOT -xzf gotip.tar.gz
export PATH="$GOROOT/bin/:$PATH"
echo "GOROOT=$GOROOT" >> $GITHUB_ENV
echo "PATH=$PATH" >> $GITHUB_ENV
echo "Active Go version:"
go version
retries=10
wait_time=30
success=false
for ((i=1; i<=retries; i++)); do
tip=$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}')
echo "Go Tip version: ${tip}"
akagami-harsh marked this conversation as resolved.
Show resolved Hide resolved
if curl_output=$(curl -fsSL -w "%{http_code}" -o gotip.tar.gz https://storage.googleapis.com/go-build-snap/go/linux-amd64/${tip}.tar.gz); then
akagami-harsh marked this conversation as resolved.
Show resolved Hide resolved
http_code=$(tail -n1 <<< "$curl_output")

if [[ "$http_code" == "404" ]]; then
echo "HTTP 404: File not found"
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
else
echo "Downloaded bundle:"
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
ls -lah gotip.tar.gz
success=true
break
fi
else
akagami-harsh marked this conversation as resolved.
Show resolved Hide resolved
echo "Failed to download. Retrying in $wait_time seconds..."
sleep $wait_time
fi
done

if [[ "$success" == true ]]; then
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
export GOROOT="$HOME/sdk/gotip"
mkdir -p $GOROOT
tar -C $GOROOT -xzf gotip.tar.gz
export PATH="$GOROOT/bin/:$PATH"
echo "GOROOT=$GOROOT" >> $GITHUB_ENV
echo "PATH=$PATH" >> $GITHUB_ENV
echo "Active Go version:"
go version
else
echo "Failed to download Go Tip after $retries attempts"
fi
Loading