Импорт репозиториев из github в gitea

Создаём в github и gitea токены, копируем скрипт и заполняем переменные.

github-to-gitea.sh
#!/bin/bash

GITHUB_USERNAME=
GITHUB_TOKEN=
GITHUB_ORGANISATION=

GITEA_USERNAME=
GITEA_TOKEN=
GITEA_DOMAIN=
GITEA_REPO_OWNER=

RES_GITHUB_API=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/user/repos?per_page=200&type=all")

REPOS=$(echo $RES_GITHUB_API | jq -r '.[] | select(.clone_url | test("'$GITHUB_USERNAME'")) | {name: .name, clone_url: .clone_url, private: .private} | @json')

for row in $REPOS; do
    REPO_NAME=$(echo $row | jq -r '.name')
    IS_PRIVATE=$(echo $row | jq -r '.private' | grep -qEi 'true' && echo true || echo false)
    URL=$(echo $row | jq -r '.clone_url')

    echo "Found $REPO_NAME, importing..."

    curl -X POST "https://$GITEA_DOMAIN/api/v1/repos/migrate" -u $GITEA_USERNAME:$GITEA_TOKEN -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \
        \"auth_username\": \"$GITHUB_USERNAME\", \
        \"auth_password\": \"$GITHUB_TOKEN\", \
        \"clone_addr\": \"$URL\", \
        \"mirror\": true, \
        \"private\": $IS_PRIVATE, \
        \"repo_name\": \"$REPO_NAME\", \
        \"repo_owner\": \"$GITEA_REPO_OWNER\", \
        \"service\": \"git\", \
        \"uid\": 0, \
        \"wiki\": false}"
done

Делаем скрипт исполняемым:

chmod +x github-to-gitea.sh

Запускаем:

./github-to-gitea.sh