1. Go to this page and download the library: Download tmd/auto-git-pull library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tmd / auto-git-pull example snippets
use Tmd\AutoGitPull\Deployer;
// IP addresses that are allowed to trigger the pull
// (CLI is always allowed)
'allowedIpRanges' => [
'131.103.20.160/27', // Bitbucket
'165.254.145.0/26', // Bitbucket
'104.192.143.0/24', // Bitbucket
'104.192.143.192/28', // Bitbucket (Dec 2015)
'104.192.143.208/28', // Bitbucket (Dec 2015)
'192.30.252.0/22', // GitHub
],
// These are added to the allowedIpRanges array
// to avoid having to define the Bitbucket/GitHub IPs in your own code
'additionalAllowedIpRanges' => [
'192.168.0.2/24'
],
// Git branch to reset to
'branch' => 'master',
// User to run the script as
'deployUser' => 'anthony',
// Directory of the repository
'directory' => '/var/www/mysite/',
// Path to the pull script
// (You can provide your own script instead)
'pullScriptPath' => __DIR__ . '/scripts/git-pull.sh',
// Git remote to fetch from
'remote' => 'origin'
]);
$deployer->postDeployCallback = function () {
echo 'Yay!';
};
$deployer->deploy();
use Monolog\Logger;
use Monolog\Handler\FingersCrossedHandler;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\NativeMailerHandler;
use Monolog\Handler\StreamHandler;
use Tmd\AutoGitPull\Deployer;
RotatingFileHandler('/var/log/mysite-deploy.log')
);
// Send an email if there's an error
$logger->pushHandler(
new FingersCrossedHandler(
new NativeMailerHandler('[email protected]', 'Deployment Failed', 'anthony@localhost', Logger::DEBUG),
new ErrorLevelActivationStrategy(Logger::ERROR)
)
);
$deployer->setLogger($logger);
$deployer->deploy();
$deployer = new \Tmd\AutoGitPull\Deployer(array(
'deployUser' => 'anthony',
// ...
));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.