Skip to content

How to mirror into an organization instead of an user #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
XargonWan opened this issue Aug 28, 2024 · 8 comments
Open

How to mirror into an organization instead of an user #20

XargonWan opened this issue Aug 28, 2024 · 8 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@XargonWan
Copy link

Greetings,

first of all, thank you for this software, it's really making the life easier!

I am using this mirrot to migrate my RetroDECK organization inside my own forgejo instance, however I noticed that in forgejo I can only generate tokens for users and not for organization so the destination of the mirroring is the user, I wish them to be migrated inside an organization named RetroDECK.
Is it possible?

Thanks in advance.

@XargonWan XargonWan changed the title How to mirro into an organization instead of an user How to mirror into an organization instead of an user Aug 28, 2024
@jaedle
Copy link
Owner

jaedle commented Sep 24, 2024

Hey 👋

I am having a look if this would be easily possible.

@jaedle jaedle added enhancement New feature or request question Further information is requested labels Sep 24, 2024
@opensourcer2
Copy link

+1

@XargonWan
Copy link
Author

Hey 👋

I am having a look if this would be easily possible.

Thanks a lot, sorry for the late reply!

@CrazyWolf13
Copy link

I'd love to see this feature as well, thanks for checking, more versatil output settings would be awesome!

@lucaspalomodevelop
Copy link

+1

@outbackdingo
Copy link

++1

@arunavo4
Copy link
Contributor

arunavo4 commented Apr 2, 2025

Hey I made something similar for the starred repos in my github account where all starred repos are moved into a organisation if the user wants. There is a PR out for it

@arunavo4
Copy link
Contributor

@XargonWan

Yes, it's absolutely possible to mirror repositories to a specific organization in Forgejo, even though you can only generate tokens for users. The mirror-to-gitea tool has a feature specifically for this purpose.

You can use the GITEA_ORGANIZATION environment variable to specify the target organization in Forgejo where all repositories should be mirrored. Here's a Docker command that should work for your use case:

docker run -it --rm \
  -e GITHUB_USERNAME="your-github-username" \
  -e GITEA_URL="https://your-forgejo-instance-url" \
  -e GITEA_TOKEN="your-user-token-from-forgejo" \
  -e GITHUB_TOKEN="your-github-token" \
  -e GITEA_ORGANIZATION="RetroDECK" \
  -e MIRROR_ORGANIZATIONS="true" \
  -e DRY_RUN="true" \
  arunavo4/mirror-to-gitea:latest

This command will:

  1. Connect to GitHub using your credentials
  2. Fetch repositories from the RetroDECK organization on GitHub
  3. Mirror them to the RetroDECK organization in your Forgejo instance
  4. Run in dry-run mode first (set to "true") so you can verify what will happen

Important notes:

  • The GITEA_ORGANIZATION variable tells the tool where to create the repositories in Forgejo
  • The organization must already exist in your Forgejo instance
  • Your user token must have permission to create repositories in that organization
  • Once you've verified everything looks good with dry-run, change DRY_RUN="true" to DRY_RUN="false" to perform the actual mirroring

If you want to preserve the organization structure from GitHub (i.e., keep the repositories in the same organization structure), you can add:

-e PRESERVE_ORG_STRUCTURE="true" \

If you only want to mirror the RetroDECK organization repositories and not your personal repositories, you can use:

-e ONLY_MIRROR_ORGS="true" \
-e INCLUDE_ORGS="RetroDECK" \

Full example with all options:

docker run -it --rm \
  -e GITHUB_USERNAME="your-github-username" \
  -e GITEA_URL="https://your-forgejo-instance-url" \
  -e GITEA_TOKEN="your-user-token-from-forgejo" \
  -e GITHUB_TOKEN="your-github-token" \
  -e GITEA_ORGANIZATION="RetroDECK" \
  -e MIRROR_ORGANIZATIONS="true" \
  -e ONLY_MIRROR_ORGS="true" \
  -e INCLUDE_ORGS="RetroDECK" \
  -e PRESERVE_ORG_STRUCTURE="true" \
  -e DRY_RUN="true" \
  arunavo4/mirror-to-gitea:latest

Let me know if you need any further assistance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants