Add adaptive checkout strategy for Gitea Actions runners.
CI / test (push) Failing after 4s

Probe multiple internal and external repository URLs, then fetch the target commit from the first reachable endpoint before running tests.

Made-with: Cursor
This commit is contained in:
2026-03-01 11:50:23 +00:00
parent 047c6f6055
commit 169a486043
+24 -2
View File
@@ -10,9 +10,31 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Prepare workspace - name: Checkout source (adaptive)
run: | run: |
ls -la set -euo pipefail
GW="$(ip route | awk '/default/ {print $3; exit}')"
CANDIDATES="
http://gitea:3000/${{ github.repository }}
http://${GW}:3000/${{ github.repository }}
http://host.docker.internal:3000/${{ github.repository }}
https://git.produktor.io/${{ github.repository }}
https://git.produktor.io/${{ github.repository }}.git
"
REPO_URL=""
for URL in ${CANDIDATES}; do
if git -c http.sslVerify=false ls-remote "${URL}" >/dev/null 2>&1; then
REPO_URL="${URL}"
break
fi
done
test -n "${REPO_URL}"
echo "Using repo URL: ${REPO_URL}"
rm -rf .git
git init .
git remote add origin "${REPO_URL}"
git -c http.sslVerify=false fetch --depth=1 origin "${{ github.sha }}"
git checkout --detach FETCH_HEAD
test -f go.mod test -f go.mod
- name: Setup Go - name: Setup Go