-
-
Save kujiy/7cd18c2b5e15020d58a7f3f185165c68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Use in the "Post-Receive URLs" section of your Bitbucket repo. | |
if ( $_POST['payload'] ) { | |
$data = json_decode($_POST['payload']); | |
$commits = $data->{"commits"}; | |
// This code checks to see if commits were made to a specific branch, and if so, performs a git reset/pull | |
foreach ($commits as $commit_obj) { | |
$branch = $commit_obj->{"branch"}; | |
if ($branch == 'my-branch') { | |
$output = shell_exec('cd /path/to/my/httpdocs && git reset --hard HEAD && git pull'); | |
echo "Output: <pre>$output</pre>"; | |
// TODO: Check for error statuses, respond appropriately | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment