Merge pull request #1204 from gentslava/fix/issue_1198-muliple_preview_deployments

fix: Multiple Preview Deployments
This commit is contained in:
Mauricio Siu
2025-01-26 15:19:00 -06:00
committed by GitHub

View File

@@ -182,8 +182,9 @@ export default async function handler(
}
} else if (req.headers["x-github-event"] === "pull_request") {
const prId = githubBody?.pull_request?.id;
const action = githubBody?.action;
if (githubBody?.action === "closed") {
if (action === "closed") {
const previewDeploymentResult =
await findPreviewDeploymentsByPullRequestId(prId);
@@ -201,7 +202,13 @@ export default async function handler(
res.status(200).json({ message: "Preview Deployment Closed" });
return;
}
// opened or synchronize or reopened
if (
action === "opened" ||
action === "synchronize" ||
action === "reopened"
) {
const repository = githubBody?.repository?.name;
const deploymentHash = githubBody?.pull_request?.head?.sha;
const branch = githubBody?.pull_request?.base?.ref;
@@ -262,7 +269,7 @@ export default async function handler(
if (IS_CLOUD && app.serverId) {
jobData.serverId = app.serverId;
await deploy(jobData);
return true;
continue;
}
await myQueue.add(
"deployments",
@@ -275,6 +282,7 @@ export default async function handler(
}
return res.status(200).json({ message: "Apps Deployed" });
}
}
return res.status(400).json({ message: "No Actions matched" });
}