DEV Community

Ian
Ian

Posted on

Git- Automatic pull on production server?

Hi,

I'm hosting my own Gitea server on which I have most of my web projects stored.

After pushing changes to a repo, I always have to connect to my shared hosting server on which I cloned the repo and run "git pull".

I know I could setup a cronjob to run this command every few minutes, but is there a better solution, which would allow an instant deployment?

Thanks!

Top comments (7)

Collapse
 
kip13 profile image
kip

You could use the webhooks and with a couple of scripts make the work, this is the simplest solution.

Another way is use Drone or gocd that kind of tools(continuous delivery/integration) use webhooks too.

Collapse
 
moopet profile image
Ben Sinclair

Can you push to the server instead? Pushing to a bare repo that only contains a hook to checkout the latest commit to the served directory is a standard way of working (or it used to be...)

You might not be able to do that, depending on your hosting, though.

Collapse
 
ian profile image
Ian

Well, that would be possible, but for convenience I'd like to use my Gitea server, since it also offers a nice UI.

Client ---> Gitea ----> Server

Collapse
 
hyperpress profile image
John Teague

You could deploy something like Drone perhaps: itnext.io/explore-gitea-drone-ci-c...

Collapse
 
ian profile image
Ian

Isn't there a simpler solution? I read something about git hooks

Collapse
 
hyperpress profile image
John Teague

Sure. You'd just need to create a script like a bash or python script, etc. But that probably puts you back in the using CRON job to run it I'd think.

If you're using an app that exposes a way to fire the script or actual book if available then that would be ideal, but my guess is you would have explored that if you had that option.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.