Skip to content

Instantly share code, notes, and snippets.

@wangyunxiang
Forked from horsley/autodeploy.php
Created January 20, 2014 02:48
Show Gist options
  • Save wangyunxiang/8514096 to your computer and use it in GitHub Desktop.
Save wangyunxiang/8514096 to your computer and use it in GitHub Desktop.
<?php
/**
* 简单自动部署
* bitbucket POST hook http://horsley:anypassword@your_host/autodeploy.php
*/
if (php_sapi_name() != 'cli') {
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
die('Restricted Area!');
} else {
if (($_SERVER['PHP_AUTH_USER'] != 'horsley') ||
($_SERVER['PHP_AUTH_PW'] != 'anypassword')
) {
die('Authentication Failed.');
}
}
}
chdir(dirname(__FILE__));
system('git pull');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment