Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: fork pr previews

Andras Bacsai9a67cf735572
diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts
index a2889ae31b..18b5aab231 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 1c6f6f9f49..3591256083 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 8540c50385..aa60aef7b7 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<ConfigureGitLab
export async function gitLabEvents(request: FastifyRequest<GitLabEvents>) {
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<GitLabEvents>) {
}
}
} 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<GitLabEvents>) {
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<GitLabEvents>) {
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 42af0f6ae8..f2f1e1e3aa 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 2debec2e80..b971164302 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 @@
</div>
{:else if application.previewApplication.length > 0}
<div
- class="grid grid-col gap-4 auto-cols-max grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"
+ class="grid grid-col gap-4 auto-cols-max grid-cols-1 md:grid-cols-2 lg:grid-cols-2 px-6"
>
{#each application.previewApplication as preview}
- <div class="no-underline mb-5 w-full lg:w-96">
+ <div class="no-underline mb-5 w-full">
<div class="w-full rounded p-5 bg-coolgray-200 indicator">
{#await getStatus(preview)}
<span class="indicator-item badge bg-yellow-500 badge-sm" />