1
0
mirror of git://f0xx.org/ac/ac-be-builder synced 2026-08-12 18:12:50 +03:00

Builder BE: docker home env + Gitea CI webhook status.

Mirror ac-ms-build runner fixes for cluster PHP-FPM (user nobody).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Anton Afanasyeu
2026-08-07 22:15:26 +02:00
parent 49183ea8d3
commit c1eb7be233
6 changed files with 224 additions and 4 deletions

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/../../src/bootstrap.php';
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
json_out(['ok' => false, 'error' => 'POST required'], 405);
}
$secret = trim((string) cfg('build.webhook_secret', ''));
$raw = file_get_contents('php://input') ?: '';
$sig = (string) ($_SERVER['HTTP_X_GITEA_SIGNATURE'] ?? $_SERVER['HTTP_X_HUB_SIGNATURE_256'] ?? '');
if ($secret !== '') {
$expected = hash_hmac('sha256', $raw, $secret);
if ($sig === '' || !hash_equals($expected, $sig)) {
json_out(['ok' => false, 'error' => 'bad_signature'], 403);
}
}
$payload = json_decode($raw, true);
if (!is_array($payload)) {
json_out(['ok' => false, 'error' => 'invalid_json'], 400);
}
try {
$build = BuildRunner::enqueueFromWebhook($payload);
json_out(['ok' => true, 'build' => $build]);
} catch (InvalidArgumentException $e) {
json_out(['ok' => false, 'error' => $e->getMessage()], 422);
} catch (Throwable $e) {
error_log('build_webhook: ' . $e->getMessage());
json_out(['ok' => false, 'error' => 'enqueue_failed'], 500);
}

View File

@@ -33,6 +33,10 @@ if ($route === '/api/heartbeat.php' || str_ends_with($route, '/api/heartbeat.php
require __DIR__ . '/api/heartbeat.php';
exit;
}
if ($route === '/api/build_webhook.php' || str_ends_with($route, '/api/build_webhook.php')) {
require __DIR__ . '/api/build_webhook.php';
exit;
}
if ($route === '/logout') {
Auth::logout();