feat(vercel): Flow to support Vercel's template deployment (#3229)
This commit is contained in:
@@ -541,6 +541,9 @@ export function VercelOnboardingModal({
|
||||
formData.append("atomicBuilds", JSON.stringify(atomicBuilds));
|
||||
formData.append("discoverEnvVars", JSON.stringify(discoverEnvVars));
|
||||
formData.append("syncEnvVarsMapping", JSON.stringify(syncEnvVarsMapping));
|
||||
if (fromMarketplaceContext) {
|
||||
formData.append("origin", "marketplace");
|
||||
}
|
||||
if (nextUrl && fromMarketplaceContext && isGitHubConnectedForOnboarding) {
|
||||
formData.append("next", nextUrl);
|
||||
}
|
||||
|
||||
@@ -1294,7 +1294,7 @@ export class VercelIntegrationRepository {
|
||||
);
|
||||
|
||||
if (envVarsResult.isErr()) {
|
||||
logger.error("pullEnvVarsFromVercel: Failed to get env vars", {
|
||||
logger.warn("pullEnvVarsFromVercel: Failed to get env vars", {
|
||||
triggerEnvType: mapping.triggerEnvType,
|
||||
vercelTarget: mapping.vercelTarget,
|
||||
error: envVarsResult.error.message,
|
||||
|
||||
+15
-1
@@ -3,7 +3,8 @@ import { parse } from "@conform-to/zod";
|
||||
import { CheckCircleIcon, LockClosedIcon, PlusIcon } from "@heroicons/react/20/solid";
|
||||
import { Form, useActionData, useNavigation, useNavigate, useSearchParams, useLocation } from "@remix-run/react";
|
||||
import { type ActionFunctionArgs, type LoaderFunctionArgs, json } from "@remix-run/server-runtime";
|
||||
import { typedjson, useTypedFetcher } from "remix-typedjson";
|
||||
import { redirect,
|
||||
typedjson, useTypedFetcher } from "remix-typedjson";
|
||||
import { z } from "zod";
|
||||
import { OctoKitty } from "~/components/GitHubLoginButton";
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTrigger } from "~/components/primitives/Dialog";
|
||||
@@ -39,6 +40,7 @@ import { findProjectBySlug } from "~/models/project.server";
|
||||
import { findEnvironmentBySlug } from "~/models/runtimeEnvironment.server";
|
||||
import { ProjectSettingsService } from "~/services/projectSettings.server";
|
||||
import { logger } from "~/services/logger.server";
|
||||
import { triggerInitialDeployment } from "~/services/platform.v3.server";
|
||||
import { requireUserId } from "~/services/session.server";
|
||||
import {
|
||||
githubAppInstallPath,
|
||||
@@ -208,6 +210,18 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
||||
);
|
||||
|
||||
if (resultOrFail.isOk()) {
|
||||
// Trigger initial deployment for marketplace flows now that GitHub is connected
|
||||
if (redirectUrl) {
|
||||
try {
|
||||
if (redirectUrl.includes("origin=marketplace")) {
|
||||
await triggerInitialDeployment(projectId, { environment: "prod" });
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error("Invalid redirect URL, skipping initial deployment trigger", { redirectUrl, error });
|
||||
// Invalid redirectUrl, skip initial deployment check
|
||||
}
|
||||
}
|
||||
|
||||
return redirectWithMessage(
|
||||
request,
|
||||
redirectUrl,
|
||||
|
||||
+1
@@ -113,6 +113,7 @@ const CompleteOnboardingFormSchema = z.object({
|
||||
syncEnvVarsMapping: z.string().optional(),
|
||||
next: z.string().optional(),
|
||||
skipRedirect: z.string().optional().transform((val) => val === "true"),
|
||||
origin: z.string().optional(),
|
||||
});
|
||||
|
||||
const SkipOnboardingFormSchema = z.object({
|
||||
|
||||
@@ -69,7 +69,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
|
||||
const parsed = VercelConnectSchema.safeParse(Object.fromEntries(url.searchParams));
|
||||
if (!parsed.success) {
|
||||
logger.error("Invalid Vercel connect params", { error: parsed.error });
|
||||
logger.warn("Invalid Vercel connect params", { error: parsed.error });
|
||||
throw new Response("Invalid parameters", { status: 400 });
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
|
||||
const validationResult = await validateVercelOAuthState(state);
|
||||
if (!validationResult.ok) {
|
||||
logger.error("Invalid Vercel OAuth state JWT", { error: validationResult.error });
|
||||
logger.warn("Invalid Vercel OAuth state JWT", { error: validationResult.error });
|
||||
|
||||
if (
|
||||
validationResult.error?.includes("expired") ||
|
||||
@@ -109,7 +109,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
});
|
||||
|
||||
if (!project) {
|
||||
logger.error("Project not found or access denied", {
|
||||
logger.warn("Project not found or access denied", {
|
||||
projectId: stateData.projectId,
|
||||
userId,
|
||||
});
|
||||
@@ -132,7 +132,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
});
|
||||
|
||||
if (!environment) {
|
||||
logger.error("Environment not found", {
|
||||
logger.warn("Environment not found", {
|
||||
projectId: project.id,
|
||||
environmentSlug: stateData.environmentSlug,
|
||||
});
|
||||
|
||||
@@ -639,6 +639,32 @@ export async function enqueueBuild(
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function triggerInitialDeployment(
|
||||
projectId: string,
|
||||
options: { environment: "preview" | "prod" | "staging" }
|
||||
): Promise<void> {
|
||||
if (!client) return;
|
||||
|
||||
const [error, result] = await tryCatch(client.triggerInitialDeployment(projectId, options));
|
||||
|
||||
if (error) {
|
||||
logger.warn("Error triggering initial deployment", {
|
||||
projectId,
|
||||
environment: options.environment,
|
||||
error,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result.success) {
|
||||
logger.warn("Failed to trigger initial deployment", {
|
||||
projectId,
|
||||
environment: options.environment,
|
||||
error: result.error,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function isCloud(): boolean {
|
||||
const acceptableHosts = [
|
||||
"https://cloud.trigger.dev",
|
||||
|
||||
@@ -413,7 +413,7 @@ export class VercelIntegrationService {
|
||||
});
|
||||
|
||||
if (upsertResult.isErr()) {
|
||||
logger.error("Failed to sync staging TRIGGER_SECRET_KEY to custom environment", {
|
||||
logger.warn("Failed to sync staging TRIGGER_SECRET_KEY to custom environment", {
|
||||
projectId,
|
||||
newCustomEnvironmentId,
|
||||
error: upsertResult.error.message,
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
"@trigger.dev/core": "workspace:*",
|
||||
"@trigger.dev/database": "workspace:*",
|
||||
"@trigger.dev/otlp-importer": "workspace:*",
|
||||
"@trigger.dev/platform": "1.0.24",
|
||||
"@trigger.dev/platform": "1.0.25",
|
||||
"@trigger.dev/redis-worker": "workspace:*",
|
||||
"@trigger.dev/sdk": "workspace:*",
|
||||
"@types/pg": "8.6.6",
|
||||
|
||||
Generated
+14
-15
@@ -510,8 +510,8 @@ importers:
|
||||
specifier: workspace:*
|
||||
version: link:../../internal-packages/otlp-importer
|
||||
'@trigger.dev/platform':
|
||||
specifier: 1.0.24
|
||||
version: 1.0.24
|
||||
specifier: 1.0.25
|
||||
version: 1.0.25
|
||||
'@trigger.dev/redis-worker':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/redis-worker
|
||||
@@ -10560,8 +10560,8 @@ packages:
|
||||
react: ^18.2.0
|
||||
react-dom: 18.2.0
|
||||
|
||||
'@trigger.dev/platform@1.0.24':
|
||||
resolution: {integrity: sha512-dg9/QWyNBCctbGhzr9U2vImUdJNR+2FqTHVTJfgrSq12BIBpwAfUiSfel1S/beEGltBKhi7KXkBAsk+9cFPPzQ==}
|
||||
'@trigger.dev/platform@1.0.25':
|
||||
resolution: {integrity: sha512-2xHol0uKwyBadXElXokuqQxsQ/0bNM0SoyX7fMl4eabbuzLYPEth1AAI1MwhF592JV3MJtVCr2POyNarw5kMXw==}
|
||||
|
||||
'@types/acorn@4.0.6':
|
||||
resolution: {integrity: sha512-veQTnWP+1D/xbxVrPC3zHnCZRjSrKfhbMUlEA43iMZLu7EsnTtkJklIuwrCPbOi8YkvDQAiW05VQQFvvz9oieQ==}
|
||||
@@ -19044,22 +19044,21 @@ packages:
|
||||
tar@6.1.13:
|
||||
resolution: {integrity: sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==}
|
||||
engines: {node: '>=10'}
|
||||
deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting i@izs.me
|
||||
|
||||
tar@6.2.1:
|
||||
resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==}
|
||||
engines: {node: '>=10'}
|
||||
deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting i@izs.me
|
||||
|
||||
tar@7.4.3:
|
||||
resolution: {integrity: sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==}
|
||||
engines: {node: '>=18'}
|
||||
deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting i@izs.me
|
||||
|
||||
tar@7.5.6:
|
||||
resolution: {integrity: sha512-xqUeu2JAIJpXyvskvU3uvQW8PAmHrtXp2KDuMJwQqW8Sqq0CaZBAQ+dKS3RBXVhU4wC5NjAdKrmh84241gO9cA==}
|
||||
engines: {node: '>=18'}
|
||||
deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
|
||||
tdigest@0.1.2:
|
||||
resolution: {integrity: sha512-+G0LLgjjo9BZX2MfdvPfH+MKLCrxlXSYec5DaPYP1fe6Iyhf0/fSmJ0bFiZ1F8BT6cGXl2LpltQptzjXKWEkKA==}
|
||||
@@ -22498,7 +22497,7 @@ snapshots:
|
||||
'@babel/traverse': 7.24.7
|
||||
'@babel/types': 7.24.0
|
||||
convert-source-map: 1.9.0
|
||||
debug: 4.4.3(supports-color@10.0.0)
|
||||
debug: 4.4.1
|
||||
gensync: 1.0.0-beta.2
|
||||
json5: 2.2.3
|
||||
semver: 6.3.1
|
||||
@@ -22786,7 +22785,7 @@ snapshots:
|
||||
'@babel/helper-split-export-declaration': 7.24.7
|
||||
'@babel/parser': 7.27.5
|
||||
'@babel/types': 7.27.3
|
||||
debug: 4.4.3(supports-color@10.0.0)
|
||||
debug: 4.4.1
|
||||
globals: 11.12.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -30897,7 +30896,7 @@ snapshots:
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
|
||||
'@trigger.dev/platform@1.0.24':
|
||||
'@trigger.dev/platform@1.0.25':
|
||||
dependencies:
|
||||
zod: 3.23.8
|
||||
|
||||
@@ -33711,7 +33710,7 @@ snapshots:
|
||||
|
||||
docker-modem@5.0.6:
|
||||
dependencies:
|
||||
debug: 4.4.3(supports-color@10.0.0)
|
||||
debug: 4.4.1
|
||||
readable-stream: 3.6.0
|
||||
split-ca: 1.0.1
|
||||
ssh2: 1.16.0
|
||||
@@ -34408,7 +34407,7 @@ snapshots:
|
||||
|
||||
eslint-import-resolver-typescript@3.5.5(@typescript-eslint/parser@5.59.6(eslint@8.31.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.7)(eslint-plugin-import@2.29.1)(eslint@8.31.0):
|
||||
dependencies:
|
||||
debug: 4.4.3(supports-color@10.0.0)
|
||||
debug: 4.4.1
|
||||
enhanced-resolve: 5.15.0
|
||||
eslint: 8.31.0
|
||||
eslint-module-utils: 2.7.4(@typescript-eslint/parser@5.59.6(eslint@8.31.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.31.0)
|
||||
@@ -35819,7 +35818,7 @@ snapshots:
|
||||
https-proxy-agent@5.0.1:
|
||||
dependencies:
|
||||
agent-base: 6.0.2
|
||||
debug: 4.4.3(supports-color@10.0.0)
|
||||
debug: 4.4.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -42266,7 +42265,7 @@ snapshots:
|
||||
vite-node@3.1.4(@types/node@20.14.14)(lightningcss@1.29.2)(terser@5.44.1):
|
||||
dependencies:
|
||||
cac: 6.7.14
|
||||
debug: 4.4.3(supports-color@10.0.0)
|
||||
debug: 4.4.1
|
||||
es-module-lexer: 1.7.0
|
||||
pathe: 2.0.3
|
||||
vite: 5.4.21(@types/node@20.14.14)(lightningcss@1.29.2)(terser@5.44.1)
|
||||
|
||||
Reference in New Issue
Block a user