Merge pull request #5444 from karan-vk/main
Feat(api): Add Pull Request deployment support to WebHooks
This commit is contained in:
19
CHANGELOG.md
19
CHANGELOG.md
@@ -54,6 +54,25 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
### 🚀 Features
|
### 🚀 Features
|
||||||
|
|
||||||
|
- *(database)* Disable MongoDB SSL by default in migration
|
||||||
|
|
||||||
|
### 🚜 Refactor
|
||||||
|
|
||||||
|
- *(proxy)* Improve port availability checks with multiple methods
|
||||||
|
- *(database)* Update MongoDB SSL configuration for improved security
|
||||||
|
- *(database)* Enhance SSL configuration handling for various databases
|
||||||
|
- *(notifications)* Update Telegram button URL for staging environment
|
||||||
|
- *(models)* Remove unnecessary cloud check in isEnabled method
|
||||||
|
- *(database)* Streamline event listeners in Redis General component
|
||||||
|
- *(database)* Remove redundant database status display in MongoDB view
|
||||||
|
- *(database)* Update import statements for Auth in database components
|
||||||
|
- *(database)* Require PEM key file for SSL certificate regeneration
|
||||||
|
- *(database)* Change MySQL daemon command to MariaDB daemon
|
||||||
|
|
||||||
|
## [4.0.0-beta.399] - 2025-03-25
|
||||||
|
|
||||||
|
### 🚀 Features
|
||||||
|
|
||||||
- *(service)* Neon
|
- *(service)* Neon
|
||||||
- *(migration)* Add `ssl_certificates` table and model
|
- *(migration)* Add `ssl_certificates` table and model
|
||||||
- *(migration)* Add ssl setting to `standalone_postgresqls` table
|
- *(migration)* Add ssl setting to `standalone_postgresqls` table
|
||||||
|
@@ -143,6 +143,7 @@ class DeployController extends Controller
|
|||||||
new OA\Parameter(name: 'tag', in: 'query', description: 'Tag name(s). Comma separated list is also accepted.', schema: new OA\Schema(type: 'string')),
|
new OA\Parameter(name: 'tag', in: 'query', description: 'Tag name(s). Comma separated list is also accepted.', schema: new OA\Schema(type: 'string')),
|
||||||
new OA\Parameter(name: 'uuid', in: 'query', description: 'Resource UUID(s). Comma separated list is also accepted.', schema: new OA\Schema(type: 'string')),
|
new OA\Parameter(name: 'uuid', in: 'query', description: 'Resource UUID(s). Comma separated list is also accepted.', schema: new OA\Schema(type: 'string')),
|
||||||
new OA\Parameter(name: 'force', in: 'query', description: 'Force rebuild (without cache)', schema: new OA\Schema(type: 'boolean')),
|
new OA\Parameter(name: 'force', in: 'query', description: 'Force rebuild (without cache)', schema: new OA\Schema(type: 'boolean')),
|
||||||
|
new OA\Parameter(name: 'pr', in: 'query', description: 'Pull Request Id for deploying specific PR builds. Cannot be used with tag parameter.', schema: new OA\Schema(type: 'integer')),
|
||||||
],
|
],
|
||||||
|
|
||||||
responses: [
|
responses: [
|
||||||
@@ -185,26 +186,32 @@ class DeployController extends Controller
|
|||||||
public function deploy(Request $request)
|
public function deploy(Request $request)
|
||||||
{
|
{
|
||||||
$teamId = getTeamIdFromToken();
|
$teamId = getTeamIdFromToken();
|
||||||
|
|
||||||
|
if (is_null($teamId)) {
|
||||||
|
return invalidTokenResponse();
|
||||||
|
}
|
||||||
|
|
||||||
$uuids = $request->query->get('uuid');
|
$uuids = $request->query->get('uuid');
|
||||||
$tags = $request->query->get('tag');
|
$tags = $request->query->get('tag');
|
||||||
$force = $request->query->get('force') ?? false;
|
$force = $request->query->get('force') ?? false;
|
||||||
|
$pr = $request->query->get('pr') ? max((int) $request->query->get('pr'), 0) : 0;
|
||||||
|
|
||||||
if ($uuids && $tags) {
|
if ($uuids && $tags) {
|
||||||
return response()->json(['message' => 'You can only use uuid or tag, not both.'], 400);
|
return response()->json(['message' => 'You can only use uuid or tag, not both.'], 400);
|
||||||
}
|
}
|
||||||
if (is_null($teamId)) {
|
if ($tags && $pr) {
|
||||||
return invalidTokenResponse();
|
return response()->json(['message' => 'You can only use tag or pr, not both.'], 400);
|
||||||
}
|
}
|
||||||
if ($tags) {
|
if ($tags) {
|
||||||
return $this->by_tags($tags, $teamId, $force);
|
return $this->by_tags($tags, $teamId, $force);
|
||||||
} elseif ($uuids) {
|
} elseif ($uuids) {
|
||||||
return $this->by_uuids($uuids, $teamId, $force);
|
return $this->by_uuids($uuids, $teamId, $force, $pr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json(['message' => 'You must provide uuid or tag.'], 400);
|
return response()->json(['message' => 'You must provide uuid or tag.'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function by_uuids(string $uuid, int $teamId, bool $force = false)
|
private function by_uuids(string $uuid, int $teamId, bool $force = false, int $pr = 0)
|
||||||
{
|
{
|
||||||
$uuids = explode(',', $uuid);
|
$uuids = explode(',', $uuid);
|
||||||
$uuids = collect(array_filter($uuids));
|
$uuids = collect(array_filter($uuids));
|
||||||
@@ -217,7 +224,7 @@ class DeployController extends Controller
|
|||||||
foreach ($uuids as $uuid) {
|
foreach ($uuids as $uuid) {
|
||||||
$resource = getResourceByUuid($uuid, $teamId);
|
$resource = getResourceByUuid($uuid, $teamId);
|
||||||
if ($resource) {
|
if ($resource) {
|
||||||
['message' => $return_message, 'deployment_uuid' => $deployment_uuid] = $this->deploy_resource($resource, $force);
|
['message' => $return_message, 'deployment_uuid' => $deployment_uuid] = $this->deploy_resource($resource, $force, $pr);
|
||||||
if ($deployment_uuid) {
|
if ($deployment_uuid) {
|
||||||
$deployments->push(['message' => $return_message, 'resource_uuid' => $uuid, 'deployment_uuid' => $deployment_uuid->toString()]);
|
$deployments->push(['message' => $return_message, 'resource_uuid' => $uuid, 'deployment_uuid' => $deployment_uuid->toString()]);
|
||||||
} else {
|
} else {
|
||||||
@@ -282,7 +289,7 @@ class DeployController extends Controller
|
|||||||
return response()->json(['message' => 'No resources found with this tag.'], 404);
|
return response()->json(['message' => 'No resources found with this tag.'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deploy_resource($resource, bool $force = false): array
|
public function deploy_resource($resource, bool $force = false, int $pr = 0): array
|
||||||
{
|
{
|
||||||
$message = null;
|
$message = null;
|
||||||
$deployment_uuid = null;
|
$deployment_uuid = null;
|
||||||
@@ -296,6 +303,7 @@ class DeployController extends Controller
|
|||||||
application: $resource,
|
application: $resource,
|
||||||
deployment_uuid: $deployment_uuid,
|
deployment_uuid: $deployment_uuid,
|
||||||
force_rebuild: $force,
|
force_rebuild: $force,
|
||||||
|
pull_request_id: $pr,
|
||||||
);
|
);
|
||||||
$message = "Application {$resource->name} deployment queued.";
|
$message = "Application {$resource->name} deployment queued.";
|
||||||
break;
|
break;
|
||||||
|
@@ -4477,6 +4477,14 @@
|
|||||||
"schema": {
|
"schema": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pr",
|
||||||
|
"in": "query",
|
||||||
|
"description": "Pull request ID",
|
||||||
|
"schema": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
@@ -3152,6 +3152,12 @@ paths:
|
|||||||
description: 'Force rebuild (without cache)'
|
description: 'Force rebuild (without cache)'
|
||||||
schema:
|
schema:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
-
|
||||||
|
name: pr
|
||||||
|
in: query
|
||||||
|
description: 'Pull request id'
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: "Get deployment(s) UUID's"
|
description: "Get deployment(s) UUID's"
|
||||||
|
Reference in New Issue
Block a user