From 017c550b9672bb48ff292506438520beac2ac86c Mon Sep 17 00:00:00 2001 From: Tracewebstudio Dev Date: Thu, 30 Apr 2026 20:33:51 +0200 Subject: [PATCH] fix(ci): prefer token owner login for gitea git auth --- .github/workflows/sync-to-gitea.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-to-gitea.yml b/.github/workflows/sync-to-gitea.yml index 5e2303d..d2d998d 100644 --- a/.github/workflows/sync-to-gitea.yml +++ b/.github/workflows/sync-to-gitea.yml @@ -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