-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
24 lines (23 loc) · 905 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
header("content-type: application/json; charset=utf-8");
$runtimeEnvironmentVariables = array_filter(
$_ENV,
fn($v, $k) => !str_starts_with($k, "PHP") && !str_starts_with($k, "APACHE"),
ARRAY_FILTER_USE_BOTH
);
$lastCommit = parseCommit(trim(file_get_contents(__DIR__ . "/commit.txt")));
echo json_encode([
"currentBranch" => trim(file_get_contents(__DIR__ . "/branch.txt")),
"lastCommit" => $lastCommit,
"buildTimeEnvironmentVariables" => json_decode(file_get_contents(__DIR__ . "/env.json")),
"runtimeEnvironmentVariables" => $runtimeEnvironmentVariables,
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
function parseCommit(string $input): array {
$output = [];
$parts = explode("|||", $input);
foreach ($parts as $part) {
[$key, $value] = explode(":::", $part);
$output[$key] = $value;
}
return $output;
}