user4831663
user4831663

Reputation:

Watch github for push and automatically pull to remote

I have been trying to move away from FTP for some time now.

After getting to grips with GIT (what have I been missing!), pushing commits to GitHub and then finally pulling the changes to my remote server I am looking to have this last stage automated (The remote server should always watch for new pushes to Github and Pull any changes).

A tutorial video I have been watching suggests using Github webhooks and a php file that executes a shell command

<?php `git pull`; ?>

I'm not entirely sure if this is the most effective way of setting up this automation, could anyone shed some light on a good approach to syncing my githhub and remote server?

Many Thanks

Thought I should edit this to show my current progress.

  1. Create simple folder structure on local machine with

index.html github.php - <?phpgit pull`; ?> (back ticks for shell command)

  1. Create git repo with GIT init
  2. Commited and pushed to github repo

  3. On remote server, created a non passworded SSH key

  4. On github, Pasted SSH key into REPO > Settings > Deploy Key

  5. Created a webhook http://makebelievemedia.co.uk/staging/test/github.php (pull_request)

As far as I am aware this should now be sending a pull_request to github.php when commits are pushed to Github which should then transfer all updated files to remote server

I think I understand the actual process well enough but think I may be missing something important, just to clarify if I run a manual PULL request on the remote server everything works fine but it is not automated which is my main goal

Upvotes: 2

Views: 1022

Answers (1)

user4831663
user4831663

Reputation:

My bad, deploy key was enter incorrectly. For anyone looking to automate github deployment I would recommend this simple approach

Upvotes: 1

Related Questions