Setting Up a Self-Hosted GitHub runner for CI/CD
from Cachvza@lemmy.world to selfhosted@lemmy.world on 17 Feb 01:36
https://lemmy.world/post/25677278

Hey everyone,

I just set up a self-hosted GitHub Actions runner in my homelab and wrote about it in my self-hosted blog! This is my second blog entry, so I would really appreciate any feedback or suggestions to help improve my writing is more than welcome.

You can check out the post here: cachaza.cc/blog/02-self-hosted-ci-cd

#selfhosted

threaded - newest

EccTM@lemmy.ml on 17 Feb 02:14 next collapse

That’s cool. Any reason why you went with a self-hosted GitHub runner over making the full jump to a self-hosted Gitea instance + runner?

d_k_bo@feddit.org on 17 Feb 06:05 next collapse

This, but Forgejo instead of Gitea.

ikidd@lemmy.world on 17 Feb 06:57 collapse

I tried this last week and it wasn’t very good. It was poorly documented, and when it failed out on a simple java CI, I just went back to act.

EccTM@lemmy.ml on 17 Feb 20:26 collapse

Yeah, the Forgejo documentation was dreadful when I last looked, it really showed its origin as a Gitea replacement for people already using (and understanding) Gitea.

[deleted] on 17 Feb 06:57 next collapse
.
Cachvza@lemmy.world on 17 Feb 12:07 collapse

My main reason was honestly laziness 😅 . I just went with what was quickest to set up. I also hadn’t realiced I could have two upstreams on my repo: one public-facing on GitHub (because I’m still in college and trying to build in public for future job opportunities) and another self-hosted on Gitea or GitLab for CI/CD.

That actually sounds like a great setup, so I’ll definitely look into it now. Thanks for the recommendation!

just_another_person@lemmy.world on 17 Feb 02:16 next collapse

Why? It’s free if you don’t setup a custom runner and those cover your areas.

ikidd@lemmy.world on 17 Feb 07:02 next collapse

1500 action minutes/mo limit.

Cachvza@lemmy.world on 17 Feb 12:11 collapse

Basically, I just wanted to tinker and learn. Self-hosting my CI/CD pipeline seemed like an interesting approach, and I wanted to explore how it all works beyond just using GitHub’s free runners.

CameronDev@programming.dev on 17 Feb 03:58 next collapse

I can’t find it right now, but there used to be a warning about not self-hosting runners for public repos. Anyone could fork your repo, and the fork would inherit your runners, and then they could change the pipeline to RCE on your runner.

Has that been fixed?

I went to a completely private gitlab instead, with mirroring up to github for anything that needed to be public.

Edit: seems to maybe not be an issue anymore, at the very least it doesn’t seem to affect that repo. Still, for anyone else, make sure forks and MRs can’t cause action to run automatically on your runner, because that would be very bad.

mumblerfish@lemmy.world on 17 Feb 06:33 next collapse

There is no auth needed for gh runners? Like a secret shared between them and the repo? I would guess repo secrets are not shared when forked… right?

CameronDev@programming.dev on 17 Feb 08:37 collapse

I think it was when you create a merge request back, that the original repo would then run the forked branch on the original runners.

From what I can tell, its now been much more locked down, so its better, but still worth being careful about.

More discussion: reddit.com/…/forks_and_selfhosted_action_runners/

The other potential risk is that the github action author maliciously modifies their code in a later version, but that is solved with version pinning the actions.

Cachvza@lemmy.world on 17 Feb 12:22 collapse

I also thought this wasn’t an issue anymore, there’s a setting in the Actions settings where you can enable or disable workflows from forked pull requests. But someone on Reddit spooked me a bit about it, so for now, I’ve made the repo private until I’m 100% sure there are no risks. I wanted it public because I was considering using GitHub Issues as a backend for blog comments, but I’ll reevaluate that. Also, thanks for the idea of running a local git server with mirroring to GitHub—I hadn’t considered having two upstreams. That could be a great setup, especially since I’m still in college and trying to build in public for future job opportunities while keeping CI/CD self-hosted.

CameronDev@programming.dev on 17 Feb 14:34 collapse

I did create a fork and MR, and neither used your runner (sorry if that is what spooked you).

Develop local and push remote also let’s you sanitize what is public and what isnt. Keep your half-backed personal projects local, push the good stuff to github for job opportunities.

Cachvza@lemmy.world on 18 Feb 01:21 collapse

No worries! When I checked the repo, I didn’t see any forks, and my Proxmox resource usage looked normal, so I didn’t think anything bad happened. I just got cautious after a Reddit user pointed out that the config I thought was safe wasn’t actually secure.

I hadn’t thought of it that way, but it makes a lot of sense. I was just avoiding committing certain things and only pushing finished work to GitHub.

ikidd@lemmy.world on 17 Feb 06:55 next collapse

I like that. I tried to get Actions in Forgejo working and that was a dead-end. So I’ve been using act manually.

Appreciate the writeup.

tofubl@discuss.tchncs.de on 17 Feb 07:27 next collapse

I have a docker forgejo runner for CI with Codeberg. Where did you get stuck?

ikidd@lemmy.world on 17 Feb 16:50 collapse

actions/setup-java@v4 would fail trying to find the java setup script at Forgejo’s runner source repo, and apparently it wasn’t there when I went to look. I’ll look at it another time when maybe all the backend is put together or there’s a way I can host the actions locally so I’m not relying on outside sources that might pollute my CI output.

arcayne@lemmy.today on 18 Feb 08:45 collapse

With both Gitea and Forgejo, sometimes you need to hardcode the action URL, like:

https://github.com/actions/setup-java@v4
ikidd@lemmy.world on 18 Feb 15:21 collapse

I followed where it was going and it was a forgejo repo where there were some action sets but not that one. I figured they were using their own sets and hadn’t gotten around to java yet.

arcayne@lemmy.today on 19 Feb 02:59 collapse

Well, yeah, thats why I’m saying if the action isn’t available directly from Forgejo, just write out the full action URL like the example in my last comment and pull it directly from GitHub. Most/all of the actions you’re pulling from Forgejo are originally forked from GitHub anyway. ¯\_(ツ)_/¯

ikidd@lemmy.world on 19 Feb 03:07 collapse

Ah, OK. Now I get your point.

Cachvza@lemmy.world on 17 Feb 12:22 collapse

Thanks!!

Selfhoster1728@infosec.pub on 17 Feb 10:38 collapse

I have a project on Forgejo and I’ve needed to set up a runner for compilation but I’ve been very confused so far on how everything works.

All I’ve been able to do is make a runner and connect it to my Forgejo instance, but I didn’t really know what to do from there.