1

We are trying to use GitHub as our version control for a WordPress/BuddyPress based site. We want to automate our 'pulls' every 5 minutes, where we keep our live server in sync with our private GitHub repo. I know I need to use cron, but I'm not sure where exactly to go from here. The server is Ubuntu based, if it matters.

Do I just need to create a cron-job where the server pulls from our GitHub repo every 5 minutes, or do we need to have a staging folder? This is where I get confused. If someone could point (or explain themselves) how to create a cron job in this scenario.

thecoshman
  • 8,394
  • 8
  • 55
  • 77
michaelrmcneill
  • 1,163
  • 1
  • 10
  • 23

2 Answers2

2

This is a cron job description that will pull changes from the origin repo every five minutes:

*/5 * * * *    cd /path/to/wordpress/repo && git pull origin master
rkb
  • 3,442
  • 19
  • 25
  • Do I pull straight into the folder wordpress/buddypress is in? Or do I pull to another folder and then do something like rsync the files? That is where I'm confused at. – michaelrmcneill Jan 30 '12 at 01:52
  • 1
    The pull creates/updates the files in the folder where you run the command. No rsync required. – rkb Jan 30 '12 at 05:11
  • sorry for taking so long to award you best answer on this one. – michaelrmcneill Apr 22 '15 at 16:49
  • Tried this approach but got an error of git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. I then modified it to add && [my passphrase] at the end but still got the error – – Mike Eng Sep 02 '20 at 22:11
0

i think, you can use a developer branch and a master branch. In the server, master branch must be active. In the local, developer branch must be active. You commit your code to developer branch and merge it with master. Etc.

After that you set the cronjob to execute your pull script git pull origin master.

You can help following links:

Community
  • 1
  • 1
hkulekci
  • 1,894
  • 15
  • 27