maxkratz / github2gitea-mirror

Mirror GitHub single repos/users/orgas/starred repos to a Gitea or Forgejo instance.
GNU Affero General Public License v3.0
46 stars 3 forks source link
bash forgejo git gitea github mirror mirroring script scripting scripts

Mirror GitHub single repos/users/orgas/starred repos to a Gitea instance

Inspiration for these scripts

Usage

Currently, there are two scripts in this repository. One is able to create mirrors for various GitHub entities and the other is capable of deleting an entire Gitea organization with all of its repositories.

Mirroring users, organizations, repos

First, setup your environment variables like this:

export ACCESS_TOKEN=123
export GITEA_URL=https://gitea.example.com
export GITHUB_TOKEN=456

There are four modes of operation, which the script can print out to the console:

./github2gitea-mirror -m

Usage: ./github2gitea-mirror
   -m, --mode {org,star,repo,user}     Mode to use; either mirror an organization or mirror all starred repositories.
   -o, --org $organization             GitHub organization to mirror and/or the target organization in Gitea.
   -u, --user $github_user             GitHub user to gather the starred repositories from.
   -v, --visibility {public,private}   Visibility for the created Gitea organization.
   -r, --repo $repo_url                GitHub URL of a single repo to create a mirror for.

Examples

Mirror a complete GitHub organization:

./github2gitea-mirror -m org -o $myOrga -v public -u $myGitHubUser

Mirror all starred GitHub repos of user $myGitHubUser:

./github2gitea-mirror -m star -u $myGitHubUser -o $myGiteaOrga

Mirror a single GitHub repository:

./github2gitea-mirror -m repo https://github.com/maxkratz/github2gitea-mirror -u $myGitHubUser

Mirror a complete GitHub user:

./github2gitea-mirror -m user -u $myGitHubUser

TODOs

Deleting Gitea organizations with all repositories

First, setup your environment variables like this:

export ACCESS_TOKEN=123
export GITEA_URL=https://gitea.example.com

Use parameter -o to pass the Gitea organization which should get deleted to the script.

Examples

Delete the Gitea organization $myGiteaOrg:

./delete_gitea_org -o $myGiteaOrg

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for more details.