mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
fix GitHub event handling for tag deployments.
This commit is contained in:
@@ -62,12 +62,11 @@ export default async function handler(
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
req.headers["x-github-event"] !== "push" &&
|
req.headers["x-github-event"] !== "push" &&
|
||||||
req.headers["x-github-event"] !== "pull_request" &&
|
req.headers["x-github-event"] !== "pull_request"
|
||||||
req.headers["x-github-event"] !== "create"
|
|
||||||
) {
|
) {
|
||||||
res
|
res
|
||||||
.status(400)
|
.status(400)
|
||||||
.json({ message: "We only accept push, pull_request, or create events" });
|
.json({ message: "We only accept push events or pull_request events" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,17 +91,17 @@ export default async function handler(
|
|||||||
|
|
||||||
// Handle tag creation event
|
// Handle tag creation event
|
||||||
if (
|
if (
|
||||||
req.headers["x-github-event"] === "create" &&
|
req.headers["x-github-event"] === "push" &&
|
||||||
githubBody?.ref_type === "tag"
|
githubBody?.ref?.startsWith("refs/tags/")
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const tagName = githubBody?.ref;
|
const tagName = githubBody?.ref.replace("refs/tags/", "");
|
||||||
const repository = githubBody?.repository?.name;
|
const repository = githubBody?.repository?.name;
|
||||||
const owner =
|
const owner =
|
||||||
githubBody?.repository?.owner?.name ||
|
githubBody?.repository?.owner?.name ||
|
||||||
githubBody?.repository?.owner?.login;
|
githubBody?.repository?.owner?.login;
|
||||||
const deploymentTitle = `Tag created: ${tagName}`;
|
const deploymentTitle = `Tag created: ${tagName}`;
|
||||||
const deploymentHash = githubBody?.master_branch || "";
|
const deploymentHash = extractHash(req.headers, githubBody);
|
||||||
|
|
||||||
// Find applications configured to deploy on tag
|
// Find applications configured to deploy on tag
|
||||||
const apps = await db.query.applications.findMany({
|
const apps = await db.query.applications.findMany({
|
||||||
@@ -120,7 +119,7 @@ export default async function handler(
|
|||||||
const jobData: DeploymentJob = {
|
const jobData: DeploymentJob = {
|
||||||
applicationId: app.applicationId as string,
|
applicationId: app.applicationId as string,
|
||||||
titleLog: deploymentTitle,
|
titleLog: deploymentTitle,
|
||||||
descriptionLog: `Tag: ${tagName}`,
|
descriptionLog: `Hash: ${deploymentHash}`,
|
||||||
type: "deploy",
|
type: "deploy",
|
||||||
applicationType: "application",
|
applicationType: "application",
|
||||||
server: !!app.serverId,
|
server: !!app.serverId,
|
||||||
@@ -159,7 +158,7 @@ export default async function handler(
|
|||||||
titleLog: deploymentTitle,
|
titleLog: deploymentTitle,
|
||||||
type: "deploy",
|
type: "deploy",
|
||||||
applicationType: "compose",
|
applicationType: "compose",
|
||||||
descriptionLog: `Tag: ${tagName}`,
|
descriptionLog: `Hash: ${deploymentHash}`,
|
||||||
server: !!composeApp.serverId,
|
server: !!composeApp.serverId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user