Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

git - auto update

v3ngv3ng Member, Host Rep

Hi,

I'm running my own Gitea instance where I'm hosting most of my web projects.
I then clone this repo to my main production server, which works without a problem.

However, I always have to run "git pull" on the production server, after I have committed some changes.

Is there a way to keep it automatically updated so I don't have to run the command every time after a change?

Thanks!

Comments

  • NeoonNeoon Community Contributor, Veteran

    git pull in a cronjob.
    Make a separate branch for that.

  • v3ngv3ng Member, Host Rep

    Is there a better way than a cronjob?

  • FHRFHR Member, Host Rep

    Could run a daemon on the server which listens for webhooks and pulls on request.

    Thanked by 2sayem314 sgheghele
  • I think it could all be automated with something like jenkins

  • YuraYura Member

    You need a CI system for that. Drone works well with Gitea, Gitlab has their own built-in. Jenkins is one of the oldest one and it's a mess but some like it.

    Thanked by 1sgheghele
  • AlyssaDAlyssaD Barred
    edited June 2019

    gitlab-ci would be a great way.

    You just tell it to scp your files to your production server. At least that is what I have done in the past. Currently I just make docker images, as they are more portable.

    
    Deploy:
        image: debian:9
        script:
            - apt-get update -qq && apt install -y -qq sshpass rsync
            - export SSHPASS=$USER_PASS
            - sshpass -e rsync -rvz --delete -e 'ssh -o stricthostkeychecking=no' web/ [email protected]:~/web/ipinfo.app/public_shtml/
        only: 
            - master
    
    

    You would need a runner for this... I am using gitlab-runner. Not sure what your product has.

  • i can also recommend gitlab ci - easy to use, provides a complete git management solution.

    and for your use case: you can create configuration gitlab-ci.yml like AlyssaD mentioned that deploys your code after building.

    but for security you should execute deploy only if unit tests etc. pass and maybe still better manually, i can guarantee oneday you will deploy a bug because of autodeploy..

    so maybe add "when:manual" it means, when pipeline passed with code analysis, unit ttests etc. u click the "deploy" button in gitlab manuall and it auto deploys.

    for some languages like php tool like "deployer" can help with deploy workflows like ssh, minify css etc.

  • iKeyZiKeyZ Veteran

    This is possible via Gitea webhooks, you could set up a webhook and call a pull after an update has gone through.

    https://docs.gitea.io/en-us/webhooks/

Sign In or Register to comment.