diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index a2889ae31..18b5aab23 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -44,7 +44,7 @@ export function getAPIUrl() { if (process.env.CODESANDBOX_HOST) { return `https://${process.env.CODESANDBOX_HOST.replace(/\$PORT/, '3001')}`; } - return isDev ? 'http://host.docker.internal:3001' : 'http://localhost:3000'; + return isDev ? 'http://localhost:3001' : 'http://localhost:3000'; } export function getUIUrl() { diff --git a/apps/api/src/routes/webhooks/github/types.ts b/apps/api/src/routes/webhooks/github/types.ts index 1c6f6f9f4..359125608 100644 --- a/apps/api/src/routes/webhooks/github/types.ts +++ b/apps/api/src/routes/webhooks/github/types.ts @@ -23,6 +23,7 @@ export interface GitHubEvents { ref: string, repo: { id: string, + full_name: string, } } } diff --git a/apps/api/src/routes/webhooks/gitlab/handlers.ts b/apps/api/src/routes/webhooks/gitlab/handlers.ts index 8540c5038..aa60aef7b 100644 --- a/apps/api/src/routes/webhooks/gitlab/handlers.ts +++ b/apps/api/src/routes/webhooks/gitlab/handlers.ts @@ -39,9 +39,7 @@ export async function configureGitLabApp(request: FastifyRequest) { const { object_kind: objectKind, ref, project_id } = request.body try { - const allowedActions = ['opened', 'reopen', 'close', 'open', 'update']; - const webhookToken = request.headers['x-gitlab-token']; if (!webhookToken && !isDev) { throw { status: 500, message: 'Invalid webhookToken.' } @@ -91,7 +89,7 @@ export async function gitLabEvents(request: FastifyRequest) { } } } else if (objectKind === 'merge_request') { - const { object_attributes: { work_in_progress: isDraft, action, source_branch: sourceBranch, target_branch: targetBranch }, project: { id } } = request.body + const { object_attributes: { work_in_progress: isDraft, action, source_branch: sourceBranch, target_branch: targetBranch, source: { path_with_namespace: sourceRepository } }, project: { id } } = request.body const pullmergeRequestId = request.body.object_attributes.iid.toString(); const projectId = Number(id); if (!allowedActions.includes(action)) { @@ -100,7 +98,6 @@ export async function gitLabEvents(request: FastifyRequest) { if (isDraft) { throw { status: 500, message: 'Draft MR, do nothing.' } } - const applicationsFound = await getApplicationFromDBWebhook(projectId, targetBranch); if (applicationsFound && applicationsFound.length > 0) { for (const application of applicationsFound) { @@ -153,6 +150,7 @@ export async function gitLabEvents(request: FastifyRequest) { id: buildId, pullmergeRequestId, previewApplicationId, + sourceRepository, sourceBranch, applicationId: application.id, destinationDockerId: application.destinationDocker.id, diff --git a/apps/api/src/routes/webhooks/gitlab/types.ts b/apps/api/src/routes/webhooks/gitlab/types.ts index 42af0f6ae..f2f1e1e3a 100644 --- a/apps/api/src/routes/webhooks/gitlab/types.ts +++ b/apps/api/src/routes/webhooks/gitlab/types.ts @@ -8,6 +8,9 @@ export interface GitLabEvents { Body: { object_attributes: { work_in_progress: string + source: { + path_with_namespace: string + } isDraft: string action: string source_branch: string diff --git a/apps/ui/src/routes/applications/[id]/previews/index.svelte b/apps/ui/src/routes/applications/[id]/previews/index.svelte index 2debec2e8..b97116430 100644 --- a/apps/ui/src/routes/applications/[id]/previews/index.svelte +++ b/apps/ui/src/routes/applications/[id]/previews/index.svelte @@ -184,10 +184,10 @@ {:else if application.previewApplication.length > 0}
{#each application.previewApplication as preview} -
+
{#await getStatus(preview)}