Created
November 9, 2023 16:42
-
-
Save Leinnan/f9f2185a8038b207e3e444e123bdf52e to your computer and use it in GitHub Desktop.
Import github repos to gitea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GITHUB_USERNAME= | |
GITHUB_TOKEN= | |
GITEA_USERNAME= | |
GITEA_TOKEN= | |
GITEA_DOMAIN= | |
GITEA_REPO_OWNER= | |
prefix=https://github.com/$GITHUB_USERNAME/ | |
GET_REPOS=$(curl -H 'Accept: application/vnd.github.v3+json' -u $GITHUB_USERNAME:$GITHUB_TOKEN -s "https://api.github.com/users/$GITHUB_USERNAME/repos?per_page=200&type=all" | jq -r '.[].html_url') | |
for URL in $GET_REPOS; do | |
REPO_NAME=${URL/#$prefix} | |
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\": false, \ | |
\"private\": true, \ | |
\"repo_name\": \"$REPO_NAME\", \ | |
\"repo_owner\": \"$GITEA_REPO_OWNER\", \ | |
\"service\": \"git\", \ | |
\"uid\": 0, \ | |
\"wiki\": true}" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment