fix: retry and validate CI source archives before extraction

This commit is contained in:
2026-10-09 22:37:17 +08:00
parent 86f1e7a897
commit c2bf4b99b8
2 changed files with 31 additions and 7 deletions
+30 -6
View File
@@ -17,9 +17,21 @@ jobs:
COMMIT_SHA: ${{ github.sha }}
run: |
set -euo pipefail
curl -fLsS -H "Authorization: token ${GITEA_TOKEN}" \
"https://git.sundynix.cn/${REPOSITORY}/archive/${COMMIT_SHA}.tar.gz" \
| tar -xz --strip-components=1
archive_path="$(mktemp)"
trap 'rm -f "$archive_path"' EXIT
archive_ready=false
for attempt in 1 2 3 4 5; do
if curl -fLsS --connect-timeout 10 --max-time 180 --retry 2 --retry-all-errors \
-H "Authorization: token ${GITEA_TOKEN}" \
"https://git.sundynix.cn/${REPOSITORY}/archive/${COMMIT_SHA}.tar.gz" \
-o "$archive_path" && tar -tzf "$archive_path" >/dev/null 2>&1; then
archive_ready=true
break
fi
sleep "$attempt"
done
test "$archive_ready" = true
tar -xzf "$archive_path" --strip-components=1
- name: Install SSH tools
run: |
set -eu
@@ -48,9 +60,21 @@ jobs:
COMMIT_SHA: ${{ github.sha }}
run: |
set -euo pipefail
curl -fLsS -H "Authorization: token ${GITEA_TOKEN}" \
"https://git.sundynix.cn/${REPOSITORY}/archive/${COMMIT_SHA}.tar.gz" \
| tar -xz --strip-components=1
archive_path="$(mktemp)"
trap 'rm -f "$archive_path"' EXIT
archive_ready=false
for attempt in 1 2 3 4 5; do
if curl -fLsS --connect-timeout 10 --max-time 180 --retry 2 --retry-all-errors \
-H "Authorization: token ${GITEA_TOKEN}" \
"https://git.sundynix.cn/${REPOSITORY}/archive/${COMMIT_SHA}.tar.gz" \
-o "$archive_path" && tar -tzf "$archive_path" >/dev/null 2>&1; then
archive_ready=true
break
fi
sleep "$attempt"
done
test "$archive_ready" = true
tar -xzf "$archive_path" --strip-components=1
- name: Install SSH tools
run: |
set -eu