优化数据获取逻辑,添加下载失败重试机制

This commit is contained in:
Ing 2025-09-27 03:37:18 +08:00
parent a1734d9a76
commit 6f7fd358d6

View File

@ -33,17 +33,13 @@ jobs:
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
- name: Delay
run: |
echo "Delaying for 1 minutes..."
sleep 60
- name: Get Data
run: |
REPO="${{ github.server_url }}/${{ github.repository }}"
PRERELEASE="true"
TAG=""
for i in {1..3}; do
if [ "${PRERELEASE}" = "true" ]; then
TAG="$(curl -skL --connect-timeout 10 "${REPO}/tags" | grep "/refs/tags/.*\.zip" | sed -E 's/.*\/refs\/tags\/(.*)\.zip.*$/\1/' | sort -rV | head -1)"
else
@ -52,8 +48,15 @@ jobs:
[ "${TAG:0:1}" = "v" ] && TAG="${TAG:1}"
rm -f rr-${TAG}.img.zip
STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${REPO}/releases/download/${TAG}/rr-${TAG}.img.zip" -o "rr-${TAG}.img.zip")
if [ $? -ne 0 ] || [ ${STATUS:-0} -ne 200 ]; then
echo "Download failed"
if [ $? -eq 0 ] && [ ${STATUS:-0} -eq 200 ]; then
break
else
echo "Download failed, retry $i/3"
sleep 60
fi
done
if [ ! -f "rr-${TAG}.img.zip" ] || [ ${STATUS:-0} -ne 200 ]; then
echo "Download failed after 3 attempts"
exit 1
fi