2

This is probably a git hook question, and a little bit of git workflow, how things should be done. This is what we are doing now:

  1. Developers have their local repos (prod, dev, test) of application in development, after changes on code and proper testing, they push or merge to central repo which is gitlab installed on hosted VPS.

  2. Besides that we have couple of remote servers that host that application where are git cloned repos from gitlab.

  3. We use git repo on each of that remote servers where we execute script pull.sh that has command lines for every branch, so that we update local repo on that servers with changes from gitlab central repo:

    git checkout prod
    git fetch origin prod
    git reset --hard origin/prod
    git pull
    

So here is the question. How can we automate update of repo on each remote server when developers push or merge changes to gitlab central repo? Now we have to SSH on each remote server and manually start script. Of course we can use cron but I'm more interested in git hooks.

Do we have to change the logic, so that after merge/push on gitlab server post-receive hook is fired and we push to remote servers? Or we can via SSH commands in post-receive script execute remotely pull.sh on remote servers?

Includell
  • 21
  • 2

0 Answers0