Created
July 6, 2022 19:45
-
-
Save TaylanTatli/51274e33bd86e0a464990a4a8583a56b to your computer and use it in GitHub Desktop.
Github To Gitea Migration
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= | |
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=$(echo $URL | sed -e "s/https:\/\/github\.com\/$GITHUB_USERNAME\///g") | |
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\", \ | |
\"auth_token\": \"$GITEA_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