Route CI LFS through Gitea

This commit is contained in:
2026-07-28 09:59:45 -07:00
parent 4162635431
commit 641c408c26
6 changed files with 63 additions and 21 deletions
+2
View File
@@ -134,6 +134,8 @@ jobs:
- name: Fetch LFS files needed for admin server
if: steps.check-latest.outputs.skip != 'true'
env:
GITEA_LFS_TOKEN: ${{ secrets.GITEA_LFS_TOKEN }}
GITEA_LFS_USERNAME: ${{ secrets.GITEA_LFS_USERNAME }}
GITHUB_TOKEN: ${{ github.token }}
run: ./ci/github_actions/fetch_lfs.sh --include="src/main/go/net/eagle0/admin_server/static/tiles/*"
+2
View File
@@ -154,6 +154,8 @@ jobs:
- name: Fetch LFS files
env:
GITEA_LFS_TOKEN: ${{ secrets.GITEA_LFS_TOKEN }}
GITEA_LFS_USERNAME: ${{ secrets.GITEA_LFS_USERNAME }}
GITHUB_TOKEN: ${{ github.token }}
run: ./ci/github_actions/fetch_lfs.sh
+2
View File
@@ -159,6 +159,8 @@ jobs:
- name: Fetch LFS files
env:
GITEA_LFS_TOKEN: ${{ secrets.GITEA_LFS_TOKEN }}
GITEA_LFS_USERNAME: ${{ secrets.GITEA_LFS_USERNAME }}
GITHUB_TOKEN: ${{ github.token }}
run: ./ci/github_actions/fetch_lfs.sh
+4
View File
@@ -148,6 +148,8 @@ jobs:
- name: Fetch LFS files
env:
GITEA_LFS_TOKEN: ${{ secrets.GITEA_LFS_TOKEN }}
GITEA_LFS_USERNAME: ${{ secrets.GITEA_LFS_USERNAME }}
GITHUB_TOKEN: ${{ github.token }}
run: ./ci/github_actions/fetch_lfs.sh
- name: Ensure Unity version installed
@@ -265,6 +267,8 @@ jobs:
- name: Fetch LFS files
env:
GITEA_LFS_TOKEN: ${{ secrets.GITEA_LFS_TOKEN }}
GITEA_LFS_USERNAME: ${{ secrets.GITEA_LFS_USERNAME }}
GITHUB_TOKEN: ${{ github.token }}
run: ./ci/github_actions/fetch_lfs.sh
- name: Ensure Unity version installed
+3
View File
@@ -0,0 +1,3 @@
[lfs]
url = https://gitea.eagle0.net/admin/eagle0-lfs.git/info/lfs
pushurl = https://gitea.eagle0.net/admin/eagle0-lfs.git/info/lfs
+50 -21
View File
@@ -1,9 +1,9 @@
#!/bin/bash
# Fetch LFS files from Gitea mirror with retry.
# Fetch LFS files from the private Gitea LFS repository with retry.
#
# Gitea's mirror-sync API is async — the webhook fires on push but the
# actual sync may still be in progress when CI starts. Retry with backoff
# to bridge the gap.
# The primary endpoint is committed in .lfsconfig. CI supplies Gitea
# credentials through GITEA_LFS_USERNAME and GITEA_LFS_TOKEN. GitHub LFS
# remains a temporary fallback while the Gitea migration is verified.
#
# Usage:
# ./ci/github_actions/fetch_lfs.sh # full pull
@@ -16,6 +16,7 @@ export PATH="${COMMON_PATHS}:${PATH}"
MAX_ATTEMPTS=5
RETRY_DELAY=15
GITEA_LFS_URL="https://gitea.eagle0.net/admin/eagle0-lfs.git/info/lfs"
if [ -n "${GITHUB_PATH:-}" ]; then
for path in /opt/homebrew/bin /usr/local/bin; do
@@ -43,34 +44,62 @@ git lfs install --local --force
echo "LFS objects before pull:"
git lfs ls-files | wc -l
GIT_LFS_PULL=(git lfs pull)
GITEA_LFS_PULL=()
FALLBACK_GITHUB_LFS_PULL=()
if [ -n "${GITEA_LFS_USERNAME:-}" ]; then
if [ -z "${GITEA_LFS_TOKEN:-}" ]; then
echo "ERROR: GITEA_LFS_TOKEN must be set when GITEA_LFS_USERNAME is set"
exit 1
fi
elif [ -n "${GITEA_LFS_TOKEN:-}" ]; then
echo "ERROR: GITEA_LFS_USERNAME must be set when GITEA_LFS_TOKEN is set"
exit 1
fi
if [ -n "${GITEA_LFS_USERNAME:-}" ]; then
GITEA_BASIC_AUTH=$(printf '%s:%s' "$GITEA_LFS_USERNAME" "$GITEA_LFS_TOKEN" | base64 | tr -d '\n')
GITEA_LFS_PULL=(
git
-c "http.https://gitea.eagle0.net/.extraheader=AUTHORIZATION: basic $GITEA_BASIC_AUTH"
-c "lfs.url=$GITEA_LFS_URL"
lfs
pull
)
elif [ "${GITHUB_ACTIONS:-}" = "true" ]; then
echo "Gitea LFS credentials are unavailable; skipping directly to the temporary GitHub fallback"
else
# Local callers can use their configured Git credential helper.
GITEA_LFS_PULL=(git -c "lfs.url=$GITEA_LFS_URL" lfs pull)
fi
if [ -n "${GITHUB_TOKEN:-}" ]; then
BASIC_AUTH=$(printf 'x-access-token:%s' "$GITHUB_TOKEN" | base64 | tr -d '\n')
GIT_LFS_PULL=(git -c "http.https://github.com/.extraheader=AUTHORIZATION: basic $BASIC_AUTH" lfs pull)
GITHUB_BASIC_AUTH=$(printf 'x-access-token:%s' "$GITHUB_TOKEN" | base64 | tr -d '\n')
FALLBACK_GITHUB_LFS_PULL=(
git
-c "http.https://github.com/.extraheader=AUTHORIZATION: basic $BASIC_AUTH"
-c "http.https://github.com/.extraheader=AUTHORIZATION: basic $GITHUB_BASIC_AUTH"
-c "lfs.url=https://github.com/nolen777/eagle0.git/info/lfs"
lfs
pull
)
fi
for i in $(seq 1 $MAX_ATTEMPTS); do
if "${GIT_LFS_PULL[@]}" "$@"; then
echo "LFS objects after pull:"
git lfs ls-files | wc -l
exit 0
fi
if [ "$i" -lt "$MAX_ATTEMPTS" ]; then
echo "LFS pull attempt $i/$MAX_ATTEMPTS failed, retrying in ${RETRY_DELAY}s..."
sleep $RETRY_DELAY
fi
done
if [ "${#GITEA_LFS_PULL[@]}" -gt 0 ]; then
for i in $(seq 1 $MAX_ATTEMPTS); do
if "${GITEA_LFS_PULL[@]}" "$@"; then
echo "LFS objects after Gitea pull:"
git lfs ls-files | wc -l
exit 0
fi
if [ "$i" -lt "$MAX_ATTEMPTS" ]; then
echo "Gitea LFS pull attempt $i/$MAX_ATTEMPTS failed, retrying in ${RETRY_DELAY}s..."
sleep "$RETRY_DELAY"
fi
done
fi
if [ "${#FALLBACK_GITHUB_LFS_PULL[@]}" -gt 0 ]; then
echo "LFS mirror pull failed after $MAX_ATTEMPTS attempts; trying GitHub LFS fallback"
echo "Trying temporary GitHub LFS fallback"
if "${FALLBACK_GITHUB_LFS_PULL[@]}" "$@"; then
echo "LFS objects after GitHub fallback pull:"
git lfs ls-files | wc -l
@@ -78,5 +107,5 @@ if [ "${#FALLBACK_GITHUB_LFS_PULL[@]}" -gt 0 ]; then
fi
fi
echo "LFS pull failed after $MAX_ATTEMPTS attempts"
echo "LFS pull failed"
exit 1