preview comments
This commit is contained in:
@@ -46,6 +46,7 @@ function queue_next_deployment(Application $application)
|
||||
application_id: $next_found->application_id,
|
||||
deployment_uuid: $next_found->deployment_uuid,
|
||||
force_rebuild: $next_found->force_rebuild,
|
||||
pull_request_id: $next_found->pull_request_id
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use App\Models\GithubApp;
|
||||
use App\Models\GitlabApp;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Lcobucci\JWT\Encoding\ChainedFormatter;
|
||||
use Lcobucci\JWT\Encoding\JoseEncoder;
|
||||
@@ -47,15 +48,22 @@ function generate_github_jwt_token(GithubApp $source)
|
||||
return $issuedToken;
|
||||
}
|
||||
|
||||
function get_from_git_api(GithubApp|GitlabApp $source, $endpoint)
|
||||
function git_api(GithubApp|GitlabApp $source, string $endpoint, string $method = 'get', array|null $data = null, bool $throwError = true)
|
||||
{
|
||||
if ($source->getMorphClass() == 'App\Models\GithubApp') {
|
||||
if ($source->is_public) {
|
||||
$response = Http::github($source->api_url)->get($endpoint);
|
||||
$response = Http::github($source->api_url)->$method($endpoint);
|
||||
} else {
|
||||
$github_access_token = generate_github_installation_token($source);
|
||||
if ($data && ($method === 'post' || $method === 'patch' || $method === 'put')) {
|
||||
$response = Http::github($source->api_url, $github_access_token)->$method($endpoint, $data);
|
||||
} else {
|
||||
$response = Http::github($source->api_url, $github_access_token)->$method($endpoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
$json = $response->json();
|
||||
if ($response->status() !== 200) {
|
||||
if ($response->failed() && $throwError) {
|
||||
throw new \Exception("Failed to get data from {$source->name} with error: " . $json['message']);
|
||||
}
|
||||
return [
|
||||
|
||||
@@ -81,3 +81,16 @@ function set_transanctional_email_settings()
|
||||
"local_domain" => null,
|
||||
]);
|
||||
}
|
||||
|
||||
function base_url()
|
||||
{
|
||||
$settings = InstanceSettings::get();
|
||||
if ($settings->fqdn) {
|
||||
return $settings->fqdn;
|
||||
} else {
|
||||
if (config('app.env') === 'local') {
|
||||
return url('/') . ':8080';
|
||||
}
|
||||
return url('/');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user