0

I want my server to fetch and pull new commits/pushes from local automatically. How do I accomplish that with a hook?

Currently, if I want to make a change, I save the file, add a commit message, push it. That updates my github repo. However, my server is now out of date of this recent change and I have to ssh into server and run command: git fetch, to determine if there are any changes and then git pull to bring it up to date.

I would like to simplify this process by the server automatically updating (pulling from github) after a change has been added (pushed locally).

Digi Jeff
  • 169
  • 1
  • 4
  • 15

1 Answers1

0

The first element to check is whether your server is reachable from GitHub.

Because if it is, you can either:

  • declare a webhook, which will make GitHub send a JSON payload on each pushed commit received. If you have set up a webhook listener on your server, you can receive that payload, and trigger the pull

  • declare a GitHub Action like this one which can push to your server bare repository, with a post-receive hook like that one to update your live site.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250