fix(ci): prefer token owner login for gitea git auth

This commit is contained in:
Tracewebstudio Dev 2026-04-30 20:33:51 +02:00
parent b6792c274e
commit d2e856c2af

View file

@ -34,6 +34,13 @@ jobs:
REPO_NAME="${{ github.event.repository.name }}"
BRANCH_NAME="${{ github.ref_name }}"
API_USER_JSON="$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" "https://${GITEA_HOST}/api/v1/user" || curl -fsS -H "Authorization: Bearer ${GITEA_TOKEN}" "https://${GITEA_HOST}/api/v1/user" || true)"
TOKEN_OWNER_USER="$(printf '%s' "$API_USER_JSON" | jq -r '.login // empty')"
if [ -n "$TOKEN_OWNER_USER" ]; then
echo "Resolved token owner user: $TOKEN_OWNER_USER"
else
echo "Could not resolve token owner via API; using configured username fallbacks"
fi
RESOLVED_GITEA_USER=""
CANDIDATE_OWNERS="${GITEA_OWNER:-} Admin ${{ github.repository_owner }}"
TARGET_FULL_NAME=""
@ -65,7 +72,7 @@ jobs:
exit 1
fi
for auth_user in "$GITEA_USERNAME" "oauth2"; do
for auth_user in "$TOKEN_OWNER_USER" "$GITEA_USERNAME" "oauth2"; do
[ -n "$auth_user" ] || continue
auth_url="https://${auth_user}:${GITEA_TOKEN}@${GITEA_HOST}/${TARGET_FULL_NAME}.git"
if git ls-remote "$auth_url" >/dev/null 2>&1; then