Migrate from Gitlab to Gitea

I had a requirement to move all of our code repos from multiple Gitlab projects to a self hosted Gitea instance I wrote the following script that uses the Gitlab API to pull a list of repos for a given 'Group', clones them all into a matching local folder then connects to the Gitea servers, creates the Repo(It just fails if it already exists) then push the code.

 1do_mirroring () {
 2    echo "Mirroring $team to $folder"
 3    mkdir $folder
 4    cd $folder
 5    #Clone all projects from this gitlab team into the folder
 6    for repo in $(curl -s --header "PRIVATE-TOKEN: gitlab-token-here" https://gitlab.com/api/v4/groups/$folder | jq -r ".projects[].ssh_url_to_repo"); do 
 7        echo "Processing $repo"
 8
 9
10        repoName=$(basename -- "$repo")
11        extension="${repoName##*.}"
12        repoName="${repoName%.*}"
13
14        echo git clone --mirror $repo $repoName; 
15        git clone --mirror $repo $repoName; 
16        cd $repoName; 
17        echo git fetch
18        git fetch
19        cd ..
20    done;
21    # #Loop through  each folder, call Gitea and create the repo, do a pull to ensure repo is up-to-date then do a git push --mirror
22    echo "Uploading to Gitea for team $team"
23    for d in */ ; do
24        d=${d%/}
25        echo "Processing $d"    
26        echo curl -k -X POST "https://my-gitea-url.local/api/v1/org/$team/repos" -H "content-type: application/json" -H "Authorization: token gitea-token-here" --data '{"name":"'$d'"}'
27        curl -k -X POST "https://my-gitea-url.local/api/v1/org/$team/repos" -H "content-type: application/json" -H "Authorization: token gitea-token-here" --data '{"name":"'$d'"}'
28        cd $d
29        # git pull
30        d=${d%/}
31
32        echo git push --mirror ssh://git@my-gitea-url.local:222/$team/$d.git
33        git push --mirror ssh://git@my-gitea-url.local:222/$team/$d.git
34        cd ..
35    done
36    cd ..
37}
38
39
40folder="11223344"
41team="OrgNameInGitea"
42do_mirroring
43
44
45folder="22446688"
46team="SomeOtherTeam"
47do_mirroring