mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-10-23 17:05:26 +00:00
Merge pull request #5732 from Totopo27/fix/gh-5659-webhook-remote-server-concurrency
fix(deploy): preserve remote serverId in webhook deployment jobs
This commit is contained in:
@@ -323,6 +323,43 @@ describe("GitHub app webhook auto-deploy", () => {
|
||||
expect(res.status).toHaveBeenCalledWith(200);
|
||||
expect(res.json).toHaveBeenCalledWith({ message: "No apps to deploy" });
|
||||
});
|
||||
|
||||
it("passes serverId to queued jobs for remote servers", async () => {
|
||||
mocks.applicationsFindMany.mockImplementation(({ where }) => {
|
||||
const matches =
|
||||
getConditionValue(where, "application.sourceType") === "github" &&
|
||||
getConditionValue(where, "application.autoDeploy") === true &&
|
||||
getConditionValue(where, "application.triggerType") === "push" &&
|
||||
getConditionValue(where, "application.branch") === "main";
|
||||
|
||||
return Promise.resolve(
|
||||
matches
|
||||
? [
|
||||
{
|
||||
applicationId: "remote-app-id",
|
||||
serverId: "remote-server-id",
|
||||
watchPaths: null,
|
||||
},
|
||||
]
|
||||
: [],
|
||||
);
|
||||
});
|
||||
const res = createResponse();
|
||||
|
||||
await handler(createPushRequest("main"), res);
|
||||
|
||||
expect(mocks.queueAdd).toHaveBeenCalledWith(
|
||||
"deployments",
|
||||
expect.objectContaining({
|
||||
applicationId: "remote-app-id",
|
||||
applicationType: "application",
|
||||
server: true,
|
||||
serverId: "remote-server-id",
|
||||
}),
|
||||
expect.anything(),
|
||||
);
|
||||
expect(res.status).toHaveBeenCalledWith(200);
|
||||
});
|
||||
});
|
||||
|
||||
describe("GitHub app webhook preview deployments", () => {
|
||||
|
||||
@@ -275,10 +275,10 @@ export default async function handler(
|
||||
type: "deploy",
|
||||
applicationType: "application",
|
||||
server: !!application.serverId,
|
||||
serverId: application.serverId ?? undefined,
|
||||
};
|
||||
|
||||
if (IS_CLOUD && application.serverId) {
|
||||
jobData.serverId = application.serverId;
|
||||
deploy(jobData).catch((error) => {
|
||||
console.error("Background deployment failed:", error);
|
||||
});
|
||||
|
||||
@@ -198,10 +198,10 @@ export default async function handler(
|
||||
applicationType: "compose",
|
||||
descriptionLog: `Hash: ${deploymentHash}`,
|
||||
server: !!composeResult.serverId,
|
||||
serverId: composeResult.serverId ?? undefined,
|
||||
};
|
||||
|
||||
if (IS_CLOUD && composeResult.serverId) {
|
||||
jobData.serverId = composeResult.serverId;
|
||||
deploy(jobData).catch((error) => {
|
||||
console.error("Background deployment failed:", error);
|
||||
});
|
||||
|
||||
@@ -144,10 +144,10 @@ export default async function handler(
|
||||
type: "deploy",
|
||||
applicationType: "application",
|
||||
server: !!app.serverId,
|
||||
serverId: app.serverId ?? undefined,
|
||||
};
|
||||
|
||||
if (IS_CLOUD && app.serverId) {
|
||||
jobData.serverId = app.serverId;
|
||||
deploy(jobData).catch((error) => {
|
||||
console.error("Background deployment failed:", error);
|
||||
});
|
||||
@@ -183,10 +183,10 @@ export default async function handler(
|
||||
applicationType: "compose",
|
||||
descriptionLog: `Hash: ${deploymentHash}`,
|
||||
server: !!composeApp.serverId,
|
||||
serverId: composeApp.serverId ?? undefined,
|
||||
};
|
||||
|
||||
if (IS_CLOUD && composeApp.serverId) {
|
||||
jobData.serverId = composeApp.serverId;
|
||||
deploy(jobData).catch((error) => {
|
||||
console.error("Background deployment failed:", error);
|
||||
});
|
||||
@@ -257,6 +257,7 @@ export default async function handler(
|
||||
type: "deploy",
|
||||
applicationType: "application",
|
||||
server: !!app.serverId,
|
||||
serverId: app.serverId ?? undefined,
|
||||
};
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
@@ -269,7 +270,6 @@ export default async function handler(
|
||||
}
|
||||
|
||||
if (IS_CLOUD && app.serverId) {
|
||||
jobData.serverId = app.serverId;
|
||||
deploy(jobData).catch((error) => {
|
||||
console.error("Background deployment failed:", error);
|
||||
});
|
||||
@@ -305,6 +305,7 @@ export default async function handler(
|
||||
applicationType: "compose",
|
||||
descriptionLog: `Hash: ${deploymentHash}`,
|
||||
server: !!composeApp.serverId,
|
||||
serverId: composeApp.serverId ?? undefined,
|
||||
};
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
@@ -316,7 +317,6 @@ export default async function handler(
|
||||
continue;
|
||||
}
|
||||
if (IS_CLOUD && composeApp.serverId) {
|
||||
jobData.serverId = composeApp.serverId;
|
||||
deploy(jobData).catch((error) => {
|
||||
console.error("Background deployment failed:", error);
|
||||
});
|
||||
@@ -526,12 +526,12 @@ export default async function handler(
|
||||
type: "deploy",
|
||||
applicationType: "application-preview",
|
||||
server: !!app.serverId,
|
||||
serverId: app.serverId ?? undefined,
|
||||
previewDeploymentId,
|
||||
};
|
||||
|
||||
if (previewDeploymentId) {
|
||||
if (IS_CLOUD && app.serverId) {
|
||||
jobData.serverId = app.serverId;
|
||||
deploy(jobData).catch((error) => {
|
||||
console.error("Background deployment failed:", error);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user