1
0
www.mikescher.com/www/commands/server_gitwebhook.php

35 lines
1020 B
PHP
Raw Normal View History

<?php
2020-01-16 13:21:14 +01:00
require_once (__DIR__ . '/../internals/website.php');
2020-01-16 13:21:14 +01:00
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
2020-01-16 13:21:14 +01:00
if (!isset($API_OPTIONS['target'])) { $FRAME_OPTIONS->forceResult(400, "Wrong parameters."); return; }
$hook = $API_OPTIONS['target'];
2020-01-16 13:21:14 +01:00
$uri = $ROUTE->full_url;
$cmd = "";
2020-01-16 13:21:14 +01:00
if ($hook == 'website_mikescher')
$cmd = 'git fetch ; git reset origin/master --hard';
2020-01-16 13:21:14 +01:00
else if ($hook == 'griddominance')
$cmd = 'update-gdapi';
else
{
$FRAME_OPTIONS->forceResult(400, "Unknown webhook: $hook");
return;
}
$std = shell_exec($cmd);
2022-10-16 15:50:38 +02:00
$content = "REQUEST: " . $uri . "\n\n" .
"IP: " . get_client_ip() . "\n\n" .
"TARGET: " . $hook . "\n\n" .
"OUTPUT: " . $std . "\n\n";
sendMail("Webhook '$hook' triggered", $content, 'virtualadmin@mikescher.de', 'webserver-info@mikescher.com');
2019-12-29 00:26:57 +01:00
echo "{ 'status': 'ok', 'message': 'Webhook '$hook' triggered' }";