-
-
Notifications
You must be signed in to change notification settings - Fork 866
feat(deployments): support local builds in cloud #2628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5d7013b
Enable skipping image push during deployment finalization step
myftija e5c4ebd
Add endpoint to generate registry credentials for a deployment
myftija c6407a2
Add a --force-local-build flag to the deployment command to skip remo…
myftija 7db5cac
Do not show the new flag in the help output
myftija fe0a507
Add changeset
myftija 26744e6
Remove registry login logs from onLog, not useful
myftija af52741
Rename var
myftija 17e7130
Update platform package to the latest version
myftija File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "trigger.dev": patch | ||
| "@trigger.dev/core": patch | ||
| --- | ||
|
|
||
| Added support for deployments with local builds. |
100 changes: 100 additions & 0 deletions
100
apps/webapp/app/routes/api.v1.deployments.$deploymentId.generate-registry-credentials.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| import { type ActionFunctionArgs, json } from "@remix-run/server-runtime"; | ||
| import { | ||
| type GenerateRegistryCredentialsResponseBody, | ||
| ProgressDeploymentRequestBody, | ||
| tryCatch, | ||
| } from "@trigger.dev/core/v3"; | ||
| import { z } from "zod"; | ||
| import { authenticateRequest } from "~/services/apiAuth.server"; | ||
| import { logger } from "~/services/logger.server"; | ||
| import { DeploymentService } from "~/v3/services/deployment.server"; | ||
|
|
||
| const ParamsSchema = z.object({ | ||
| deploymentId: z.string(), | ||
| }); | ||
|
|
||
| export async function action({ request, params }: ActionFunctionArgs) { | ||
| if (request.method.toUpperCase() !== "POST") { | ||
| return json({ error: "Method Not Allowed" }, { status: 405 }); | ||
| } | ||
|
|
||
| const parsedParams = ParamsSchema.safeParse(params); | ||
|
|
||
| if (!parsedParams.success) { | ||
| return json({ error: "Invalid params" }, { status: 400 }); | ||
| } | ||
|
|
||
| const authenticationResult = await authenticateRequest(request, { | ||
| apiKey: true, | ||
| organizationAccessToken: false, | ||
| personalAccessToken: false, | ||
| }); | ||
|
|
||
| if (!authenticationResult || !authenticationResult.result.ok) { | ||
| logger.info("Invalid or missing api key", { url: request.url }); | ||
| return json({ error: "Invalid or Missing API key" }, { status: 401 }); | ||
| } | ||
|
|
||
| const { environment: authenticatedEnv } = authenticationResult.result; | ||
| const { deploymentId } = parsedParams.data; | ||
|
|
||
| const [, rawBody] = await tryCatch(request.json()); | ||
| const body = ProgressDeploymentRequestBody.safeParse(rawBody ?? {}); | ||
|
|
||
| if (!body.success) { | ||
| return json({ error: "Invalid request body", issues: body.error.issues }, { status: 400 }); | ||
| } | ||
|
|
||
| const deploymentService = new DeploymentService(); | ||
|
|
||
| return await deploymentService.generateRegistryCredentials(authenticatedEnv, deploymentId).match( | ||
| (result) => { | ||
| return json( | ||
| { | ||
| username: result.username, | ||
| password: result.password, | ||
| expiresAt: result.expiresAt.toISOString(), | ||
| repositoryUri: result.repositoryUri, | ||
| } satisfies GenerateRegistryCredentialsResponseBody, | ||
| { status: 200 } | ||
| ); | ||
| }, | ||
| (error) => { | ||
| switch (error.type) { | ||
| case "deployment_not_found": | ||
| return json({ error: "Deployment not found" }, { status: 404 }); | ||
| case "deployment_has_no_image_reference": | ||
| logger.error( | ||
| "Failed to generate registry credentials: deployment_has_no_image_reference", | ||
| { deploymentId } | ||
| ); | ||
| return json({ error: "Deployment has no image reference" }, { status: 409 }); | ||
| case "deployment_is_already_final": | ||
| return json( | ||
| { error: "Failed to generate registry credentials: deployment_is_already_final" }, | ||
| { status: 409 } | ||
| ); | ||
| case "missing_registry_credentials": | ||
| logger.error("Failed to generate registry credentials: missing_registry_credentials", { | ||
| deploymentId, | ||
| }); | ||
| return json({ error: "Missing registry credentials" }, { status: 409 }); | ||
| case "registry_not_supported": | ||
| logger.error("Failed to generate registry credentials: registry_not_supported", { | ||
| deploymentId, | ||
| }); | ||
| return json({ error: "Registry not supported" }, { status: 409 }); | ||
| case "registry_region_not_supported": | ||
| logger.error("Failed to generate registry credentials: registry_region_not_supported", { | ||
| deploymentId, | ||
| }); | ||
| return json({ error: "Registry region not supported" }, { status: 409 }); | ||
| case "other": | ||
| default: | ||
| error.type satisfies "other"; | ||
| logger.error("Failed to generate registry credentials", { error: error.cause }); | ||
| return json({ error: "Internal server error" }, { status: 500 }); | ||
| } | ||
| } | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.