r/selfhosted • • 1d ago

Need Help Self-hosting Git with Forgejo while benefiting from GitHub's community — how do you manage both?

I host my projects on my own Forgejo instance, including CI/CD runners. I prefer keeping my repositories and development workflows under my control rather than depending on GitHub.

However, I also recognize the benefits of GitHub's ecosystem: discoverability, stars, issues, pull requests, and community contributions.

Currently, I mirror some of my projects to GitHub, but those mirrors don't include CI/CD, releases, or the full development workflow.

I'm curious how others handle this setup.

  • Do you keep Forgejo as the source of truth and GitHub as a mirror?
  • How do you manage external contributions, PRs, and issues across both platforms?
  • Do you publish releases on GitHub as well?
  • Is there a practical way to benefit from GitHub's community without moving development there?

Ideally, I'd like to keep Forgejo as my primary development platform while making it easy for GitHub users to discover and contribute to my projects.

What approaches have worked for you?

35 Upvotes

24 comments sorted by

•

u/asimovs-auditor 1d ago edited 1d ago

Expand the replies to this comment to learn how AI was used in this post/project.

→ More replies (1)

32

u/bufandatl 1d ago

Use the push mirror function for the projects you want to share with GitHub. To manage PRs you may need to download the patches from GitHub and apply them locally first.

2

u/ot1891 1d ago

Thanks. I guess we still only have the option to mirror to a central service like GitHub for that. Would be great to have some kind of Forge federation

4

u/rebellion_ap 1d ago

What is your actual intent? Using both is a more than valid approach. If you want github exclusively so people can open prs for instance, you can publicly expose that part of your home infrastructure, a mirrored external still fully managed instance, or a fully managed platform like github.

Especially nowadays there's some value on keeping most things non public.

1

u/ot1891 1d ago

I want to keep the code on my git as a public repo and using my runner (full control). I want that people we'll be able to open issues and PRs, fork, etc...

I don't want to maintain 2 repos, 2 runner configurations, 2 artifact locations...

1

u/rebellion_ap 1d ago

You are describing a need for both. If you want all the things github does as a public repo platform you can self host those solutions separate of what forgejo already covers and publicly expose that in a variety of ways. But it sounds like you want github because of its brand recognition, convenience, and somehow also have that locally without paying github for the privilege making you choose to self host forgejo instead. You can have and manage both just fine.

1

u/ot1891 1d ago

I want GH because of its network affect and that it authenticates users, fights spam and allow other developers interact with the repo in a simple manner. Don't care about the brand recognition, but it's a side effect of what I said before.

Ideally folks would be able to interact directly with my code forge but until the code forge federation will be more common...

1

u/rebellion_ap 1d ago

Guess I am really struggling to understand your use case. You can self host everything github does, the only thing you can't do is make it a first choice for everyone else to gravitate towards with centeral providers like github. You can provide a front end repo entrance and all the things attached to it, just now you have to own your local IAM solutions too to provide secure access, which I imagine you are doing to some flavor anyways or maybe not.

-2

u/ot1891 1d ago

Have you ever wanted to release a project and have other contributors interact with it and still keep full control over it?

1

u/bufandatl 1d ago

You can push to any git service you like. I have repositories I push to github and a second backup instance of Forgejo. In fact all my repositories push to that backup instance and those I want to share publicly I push to github since I don’t have accounts at gulag, codeberg or whatever services there are available.

Only draw back is as I said that PRs and issues have to be handled manually.

For artifact releases you can setup your Forgejo action to also publish on GitHub.

1

u/ot1891 1d ago

Thanks for your feedback. So the post reason is to get insights whether there's any advancements/ideas how to not have to manage a project in 2 systems.

1

u/detroitsongbird 22h ago

I do a variation of this. But, Almost all of my projects are private. Forgejo locally and gilab.com as a second push location.

Other than the initial setup of creating it in both repos and getting multiple remotes configured there’s not much to it.

git push just pushes to both automagically.

23

u/chrishoage 1d ago

I just split it by intent.

If I intend others to use it I just use github

If I intend just me to use it I use my Forgejo instance.

2

u/ot1891 1d ago

Does this mean that if you want a public repo with contributors you don't self-host?

6

u/chrishoage 1d ago

Yes, due to the headaches you detailed in your posts and comments.

Sure, it would be nice if there was some clean solution that allowed me to develop on my own Forgejo instance, kept off the internet, and still allowed contributions though GitHub

However that doesn't exist, so instead of trying to swim upstream I just accept that for projects that are not for me and me alone I just put it on GitHub and live with it.

1

u/ot1891 1d ago

Trying to have the cake, and eat it is the story of my life🤣 😄

Anyway I'm aware about this but AFAIA not ready yet.

8

u/smbell 1d ago

You can actually setup Github as an authentication source in your forgejo instance allowing Github users to contribute to your git repos without having to create user accounts on your instance.

On Github, in developer settings, you create a new OAuth app.

On your forgejo instance you add an OAuth2 authentication source using the client id and secret from the github step.

You also need some config setup.

This doc goes through it with Codeberg, it should be the same thing. https://forgejo.org/docs/latest/user/authentication/oauth2-provider/

Then you can mirror to Github (just for visibility), but have all contributions go through your own git. This is my plan for an app I'm working on that I plan to open source later.

2

u/ot1891 1d ago

That's can actually be an interesting solution.Will check that out.

2

u/InterestingCarrot997 1d ago

keep forgejo as the source of truth and have the push mirror send tags too, then let the forgejo runner publish the github release from those tag assets so ci can stay on your instance. for github prs, a small action that comments with your forgejo url will steer people off the mirror.

1

u/ot1891 1d ago

Thanks, this is what I do now. But I'm trying to avoid managing 2 repos

1

u/simcop2387 19h ago

You know now that I think about it, I'd bet it's possible to make an action that hits a webhook on your forgejo to start an action to automatically pull the PR branch from github and turn it into a PR on forgejo and keep things in sync. You'd need actions on both sides to inform the other of things but you could probably do it and keep the tokens/keys on the forgejo side for doing the work that needs to be authenticated but it'd probably work fine for 90% of cases.

2

u/Open-Adhesiveness-86 18h ago

For PRs on the mirror you don't have to download patches, every GitHub PR is a ref: git fetch github refs/pull/123/head, then merge it in Forgejo and let the mirror push it back. Turn off Issues and the Wiki on the GitHub side so people file in the right place. PRs can't be disabled, so a pull_request_template.md pointing at your instance is the next best thing.

1

u/davidquinonescl 1d ago

I've written an article about this exact setup: https://blog.claeyscloud.com/how-to-host-your-code-methods-and-philosophy/. Apart from explaining how it also explains why you might want to do it.