Skip to content

Instantly share code, notes, and snippets.

@GiovanniK
Created April 25, 2015 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GiovanniK/22d8ab1ed9137d9bfb12 to your computer and use it in GitHub Desktop.
Save GiovanniK/22d8ab1ed9137d9bfb12 to your computer and use it in GitHub Desktop.
Git webhook
<?php
$dir = __DIR__ . '/..';
$keys = [
'mijnkey'
];
$lock = $dir . '/DEPLOY.LOCK';
if (!file_exists($lock)) {
if (isset($_GET['key']) && in_array($_GET['key'], $keys)) {
file_put_contents($lock, time());
shell_exec("cd $dir && php artisan down");
shell_exec("cd $dir && git reset --hard origin/master");
shell_exec("cd $dir && git pull 2>&1");
shell_exec("cd $dir && composer install");
shell_exec("cd $dir && cd ../ && cp .env manager");
shell_exec("cd $dir && php artisan up");
unlink($lock);
}
}
echo 'Ok!';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment