Skip to content

Commit d61db95

Browse files
fix(webapp): gate native Git-based deployments and enqueueBuild on cloud build client availability
Fixes #4835
1 parent aed0848 commit d61db95

5 files changed

Lines changed: 25 additions & 6 deletions

File tree

‎apps/webapp/app/presenters/v3/DeploymentListPresenter.server.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
VercelProjectIntegrationDataSchema,
1515
buildVercelDeploymentUrl,
1616
} from "~/v3/vercel/vercelProjectIntegrationSchema";
17+
import { isBillingConfigured } from "~/services/platform.v3.server";
1718
import { resolveRedeploySource } from "~/v3/redeploy";
1819

1920
const pageSize = 20;
@@ -225,13 +226,15 @@ LIMIT ${pageSize} OFFSET ${pageSize * (page - 1)};`;
225226
currentPage: page,
226227
totalPages: Math.ceil(totalCount / pageSize),
227228
hasVercelIntegration,
228-
connectedGithubRepository: project.connectedGithubRepository ?? undefined,
229-
environmentGitHubBranch,
229+
connectedGithubRepository: isBillingConfigured()
230+
? (project.connectedGithubRepository ?? undefined)
231+
: undefined,
232+
environmentGitHubBranch: isBillingConfigured() ? environmentGitHubBranch : undefined,
230233
deployments: deployments.map((deployment, index) => {
231234
const label = labeledDeployments.find(
232235
(labeledDeployment) => labeledDeployment.deploymentId === deployment.id
233236
);
234-
const redeploySource = resolveRedeploySource(deployment);
237+
const redeploySource = isBillingConfigured() ? resolveRedeploySource(deployment) : null;
235238

236239
let vercelDeploymentUrl: string | null = null;
237240
if (

‎apps/webapp/app/presenters/v3/GitHubSettingsPresenter.server.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { type PrismaClient } from "@trigger.dev/database";
22
import { fromPromise, ok, ResultAsync } from "neverthrow";
33
import { env } from "~/env.server";
4+
import { isBillingConfigured } from "~/services/platform.v3.server";
45
import { BranchTrackingConfigSchema } from "~/v3/github";
56
import { BasePresenter } from "./basePresenter.server";
67

@@ -11,7 +12,7 @@ type GitHubSettingsOptions = {
1112

1213
export class GitHubSettingsPresenter extends BasePresenter {
1314
public call({ projectId, organizationId }: GitHubSettingsOptions) {
14-
const githubAppEnabled = env.GITHUB_APP_ENABLED === "1";
15+
const githubAppEnabled = env.GITHUB_APP_ENABLED === "1" && isBillingConfigured();
1516

1617
if (!githubAppEnabled) {
1718
return ok({

‎apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.github.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import { findEnvironmentBySlug } from "~/models/runtimeEnvironment.server";
7171
import { env } from "~/env.server";
7272
import { GitHubSettingsPresenter } from "~/presenters/v3/GitHubSettingsPresenter.server";
7373
import { logger } from "~/services/logger.server";
74-
import { triggerInitialDeployment } from "~/services/platform.v3.server";
74+
import { isBillingConfigured, triggerInitialDeployment } from "~/services/platform.v3.server";
7575
import { marketplaceInitialDeploymentOptions } from "~/v3/services/marketplaceInitialDeploymentOptions.server";
7676
import { ProjectSettingsService } from "~/services/projectSettings.server";
7777
import { rbac } from "~/services/rbac.server";
@@ -241,6 +241,13 @@ export const action = dashboardAction(
241241
throw new Response("Not Found", { status: 404 });
242242
}
243243

244+
if (env.GITHUB_APP_ENABLED !== "1" || !isBillingConfigured()) {
245+
return json(
246+
{ ok: false, error: "Native GitHub deployments are not available on self-hosted instances." },
247+
{ status: 403 }
248+
);
249+
}
250+
244251
const formData = await request.formData();
245252
const submission = parseWithZod(formData, { schema: GitHubActionSchema });
246253

‎apps/webapp/app/services/platform.v3.server.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ export async function enqueueBuild(
11781178
fromBundle?: boolean;
11791179
}
11801180
) {
1181-
if (!client) return undefined;
1181+
if (!client) throw new Error("Platform client not configured");
11821182
const result = await client.enqueueBuild(projectId, { deploymentId, artifactKey, options });
11831183
if (!result.success) {
11841184
recordPlatformFailure("enqueueBuild", "no_success");

‎apps/webapp/app/v3/services/initializeDeployment.server.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { resolveDeployBaseImages } from "../deployBaseImages.server";
1818
import { getDeploymentImageRef } from "../getDeploymentImageRef.server";
1919
import { tryCatch } from "@trigger.dev/core";
2020
import { getRegistryConfig } from "../registryConfig.server";
21+
import { isBillingConfigured } from "~/services/platform.v3.server";
2122
import { DeploymentService } from "./deployment.server";
2223
import { recordDeploymentInitialized } from "./recordDeploymentFinished.server";
2324
import { buildEnvVarsEnvelope } from "./initializeDeployment/buildEnvVarsEnvelope.server";
@@ -149,6 +150,13 @@ export class InitializeDeploymentService extends BaseService {
149150
throw new ServiceValidationError("UNMANAGED deployments are not supported");
150151
}
151152

153+
if (payload.isNativeBuild && !isBillingConfigured()) {
154+
throw new ServiceValidationError(
155+
"Native builds are not supported on self-hosted instances. Deploy with the CLI or GitHub Actions instead.",
156+
400
157+
);
158+
}
159+
152160
const requiredBaseImages = resolveDeployBaseImages(runtime, {
153161
base: env.DEPLOY_BASE_IMAGES,
154162
buildBase: env.DEPLOY_BUILD_BASE_IMAGES,

0 commit comments

Comments
 (0)