1
0
mirror of git://f0xx.org/ac/ac-ms-build synced 2026-08-12 18:13:16 +03:00

Builder: docker home env + Gitea CI webhook status.

Export HOME/DOCKER_CONFIG for nobody PHP-FPM, improve docker health
checks, and report build status to Gitea when enabled.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Anton Afanasyeu
2026-08-07 22:15:26 +02:00
parent 8c59662245
commit 1fa8da68d5
5 changed files with 220 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);
}