-
-
Save phedoreanu/11321236 to your computer and use it in GitHub Desktop.
| sudo mkdir -m 0700 /var/www/.ssh | |
| sudo chown -R apache:apache /var/www/.ssh | |
| sudo -u apache ssh-keygen (empty passphrase) | |
| paste public key into repo manager | |
| (git-repo) sudo -u apache git pull origin branch (this will create /var/www/.ssh/known_hosts) | |
| call git_hook.php?branch=xxx |
| <?php | |
| $gh_ips = array('171.149.246.236', '95.92.138.4'); | |
| if (in_array($_SERVER['REMOTE_ADDR'], $gh_ips) === false) { | |
| header('Status: 403 Your IP is not on our list; bugger off', true, 403); | |
| mail('root', 'Unfuddle hook error: bad ip', $_SERVER['REMOTE_ADDR']); | |
| die(1); | |
| } | |
| $BRANCH = $_GET['branch']; | |
| if (!empty($BRANCH)) { | |
| $output = shell_exec("cd /srv/www/git-repo/; git pull origin {$BRANCH};"); | |
| echo "<pre>$output</pre>"; | |
| } | |
| die("done " . mktime()); |
@JackdeVilliers
It's here: https://github.com/_yourLogin/_repoName/settings/keys
I'm trying to understand all of this, I've been struggling on all of this for like 4 hours now. I'm just trying to catch the webhook from my Github repo, and if I catch it : launch a script to "git pull" ! I know a bit of php so I thought it wouldn't be too difficult but know : either apache doesn't have the right permissions to perform any of my commands (like exec or anything else), so I came here to see that with a customization of ssh I could maybe overcome this difficulty, and maybe, but I don't understand the "call git_hook.php?branch=xxx" part... Do I have to call "myserver.com/.../git_hook.php?branch=xxx" in the webhook ?
I'm just lost and tired so I really like to make a clear, simple solution for webhooks-autopull ...
I know this is a silly question, but where do I access the repo manager, as part of this step above:
paste public key into repo manager