Automatic Pulls on Linux

Hello GitHub Community!

I’m looking for a “System” that detects when something gets merged/pushed into the main branch of a Project.

For example…

I have a project that has a “test” branch and the default “main” branch

we usually push into the test branch first to test everything and if it works fine we push it into the master branch.

We have a Minecraft Server running and some plugins for Custom Items etcetera, currently when I merge something into the main branch I always need to do git pull inside the correct directory, but I’m looking for a way that it automatically pulls when something is pushed/merged into the main branch.

Is something like this possible?
We use Ubuntu 20.04 with git installed.

I hope my question is Understandable, English isn’t my native language and i didn’t use it for a long time :sweat_smile:

I see two options:

  1. Use a cron job (or timer unit, if your server uses systemd) to regularly run git pull. Not that elegant because it’s simply a regular check for updates and doesn’t react specifically to your push (so there will be some delay, especially because you shouldn’t run it every few minutes), but very simple.
  2. Set up a webhook to make GitHub send you HTTP POST requests when certain events happen (e.g. a push). It allows you to react very quickly to events as they happen without periodic checks, but you need a server that can handle the incoming requests, so it’s more work to set up. For details see: About webhooks - GitHub Docs