feat: add idempotent token deletion before generating new Gitea admin token
This commit is contained in:
@@ -129,6 +129,13 @@ if [[ -n "${GITEA_ADMIN_TOKEN:-}" ]]; then
|
||||
fi
|
||||
|
||||
if [[ -z "${GITEA_ADMIN_TOKEN:-}" ]]; then
|
||||
# Delete any stale token with the same name (idempotent re-run safety).
|
||||
# Gitea returns 409 Conflict if a token with this name already exists.
|
||||
curl -sf -u "${GITEA_ADMIN_USER}:${GITEA_ADMIN_PASSWORD}" \
|
||||
-X DELETE \
|
||||
"${GITEA_INTERNAL_URL}/api/v1/users/${GITEA_ADMIN_USER}/tokens/migration-token" \
|
||||
-o /dev/null 2>/dev/null || true
|
||||
|
||||
# Generate token using basic auth (username:password).
|
||||
# The .sha1 field in the response contains the full token — this is the
|
||||
# ONLY time it's returned, so we must save it immediately.
|
||||
|
||||
Reference in New Issue
Block a user