GitHub – setup auto deployment with remote server

Currently, my production website is hosted on Azure. I use git and push all my commits to GitHub. With the magic of git hooks Azure has the ability to pull from GitHub when someone pushes a certain branch to GitHub.

How can I replicate this with my own staging server hosted on-premise? In other words, how can I set a repo on GitHub, and when I push to it, through git hooks send a signal, request or what-have-you to perform an automatic pull on my on-premise server?

I know Git is not a deployment software, but if I have to write a mechanism on my on-prmise server to make this happen I would like to know where to start. If it’s helpful, we use Microsoft technology, so we are running our staging server on Windows Server, while our production is on Azure.

I understand that I’ll need to use callback url on my server to then perform whatever is needed.I would like to know what methods people use to accomplish this. e.g.: on my call back url, how would I call a script to run a pull/fetch/clone bash command. or other method.

If you need more information, feel free to ask.

  • If we delete a branch on the server, can we automatically delete it in our local copy?
  • Why do people fork and then don't change anything?
  • Recovering from git push -f
  • Git pre-commit hook check message
  • Can't get new files from git branch - 'Already up-to-date'
  • Where exactly does the Remote Branch point to after fetching?
  • Get TYPO3 trunk from github by git
  • Where are the Git branches stored?
  • One Solution collect form web for “GitHub – setup auto deployment with remote server”

    Expanding upon my comment,

    1. You would need to define/create a callback url on your end, which
      will need to be publicly accessible.

    2. github would make a hit to this url via a git hook whenever a
      push is made to the branch in question.

    3. You can add authentication for the hit in the hook, if needed.

    4. This call will inform your server that a push has been made to the
      certain branch on github.

    5. Now your server should start a deployment task which does the
      pull/clone.

    Regarding this deployment task, there are many ways to do this, and the finer details will vary depending on how you do it.

    One way would be to introduce a Continuous Integration tool like Jenkins in your stack, which you could also use for regular and test builds in different environments.

    Another way could be to execute a simple bash script which does cd $REPO_DIR && git pull origin branchname && service apache2 etc restart.

    Git Baby is a git and github fan, let's start git clone.