From 97c21a489418cbecd23ca58bc223a16c6f0ca0a4 Mon Sep 17 00:00:00 2001 From: Troy grunt Date: Wed, 31 Dec 2025 01:47:32 +0100 Subject: [PATCH] gitea stuff --- troy-api.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/troy-api.php b/troy-api.php index 56ca06b..8540d40 100644 --- a/troy-api.php +++ b/troy-api.php @@ -13,4 +13,37 @@ function sendToTroy($data) { $context = stream_context_create ( $options ); return file_get_contents ( $url, false, $context ); } -?> \ No newline at end of file + +function sendToGitea($title, $message) { + // secret.php liegt in lib/ + require 'secret.php'; + + $url = rtrim($giteaUrl, '/') . "/repos/$giteaOwner/$giteaRepo/issues"; + + $data = [ + "title" => $title, + "body" => $message + ]; + + $options = [ + 'http' => [ + 'method' => 'POST', + 'header' => [ + "Content-Type: application/json", + "Authorization: token $giteaToken" + ], + 'content' => json_encode($data) + ] + ]; + + $context = stream_context_create($options); + $result = file_get_contents($url, false, $context); + + if ($result === FALSE) { + throw new Exception("Fehler beim Erstellen der Anfrage"); + } + + return json_decode($result, true); +} + +?>