#!/usr/bin/env php
<?php

declare(strict_types=1);

// A Web Apps deploy's ExecStopPost, as root: records how the build ended and starts the new release
require dirname(__DIR__, 2) . '/vendor/autoload.php';

use Bakkbone\Agent\Bootstrap;

[, $user, $name, $deployId, $category] = $argv + array_fill(0, 5, '');
$record = Bootstrap::webApps()->finish($user, $name, $deployId, $category, (string) getenv('SERVICE_RESULT'), (string) getenv('EXIT_STATUS'));
fwrite(STDERR, "web app {$user}/{$name} deploy {$deployId}: {$record['result']}\n");
