fix(ci): prefer token owner login for gitea git auth
This commit is contained in:
parent
b6792c274e
commit
d2e856c2af
1 changed files with 8 additions and 1 deletions
9
.github/workflows/sync-to-gitea.yml
vendored
9
.github/workflows/sync-to-gitea.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue