mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-09 05:25:18 +00:00
feat: add support for preview labels in deployment process
This commit is contained in:
@@ -1,22 +1,22 @@
|
|||||||
import { db } from "@/server/db";
|
|
||||||
import { applications, compose, github } from "@/server/db/schema";
|
|
||||||
import type { DeploymentJob } from "@/server/queues/queue-types";
|
|
||||||
import { myQueue } from "@/server/queues/queueSetup";
|
|
||||||
import { deploy } from "@/server/utils/deploy";
|
|
||||||
import {
|
import {
|
||||||
IS_CLOUD,
|
|
||||||
checkUserRepositoryPermissions,
|
checkUserRepositoryPermissions,
|
||||||
createPreviewDeployment,
|
createPreviewDeployment,
|
||||||
createSecurityBlockedComment,
|
createSecurityBlockedComment,
|
||||||
findGithubById,
|
findGithubById,
|
||||||
findPreviewDeploymentByApplicationId,
|
findPreviewDeploymentByApplicationId,
|
||||||
findPreviewDeploymentsByPullRequestId,
|
findPreviewDeploymentsByPullRequestId,
|
||||||
|
IS_CLOUD,
|
||||||
removePreviewDeployment,
|
removePreviewDeployment,
|
||||||
shouldDeploy,
|
shouldDeploy,
|
||||||
} from "@dokploy/server";
|
} from "@dokploy/server";
|
||||||
import { Webhooks } from "@octokit/webhooks";
|
import { Webhooks } from "@octokit/webhooks";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import type { NextApiRequest, NextApiResponse } from "next";
|
import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
|
import { db } from "@/server/db";
|
||||||
|
import { applications, compose, github } from "@/server/db/schema";
|
||||||
|
import type { DeploymentJob } from "@/server/queues/queue-types";
|
||||||
|
import { myQueue } from "@/server/queues/queueSetup";
|
||||||
|
import { deploy } from "@/server/utils/deploy";
|
||||||
import { extractCommitMessage, extractHash } from "./[refreshToken]";
|
import { extractCommitMessage, extractHash } from "./[refreshToken]";
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
@@ -343,7 +343,9 @@ export default async function handler(
|
|||||||
if (
|
if (
|
||||||
action === "opened" ||
|
action === "opened" ||
|
||||||
action === "synchronize" ||
|
action === "synchronize" ||
|
||||||
action === "reopened"
|
action === "reopened" ||
|
||||||
|
action === "labeled" ||
|
||||||
|
action === "unlabeled"
|
||||||
) {
|
) {
|
||||||
const repository = githubBody?.repository?.name;
|
const repository = githubBody?.repository?.name;
|
||||||
const deploymentHash = githubBody?.pull_request?.head?.sha;
|
const deploymentHash = githubBody?.pull_request?.head?.sha;
|
||||||
@@ -443,11 +445,11 @@ export default async function handler(
|
|||||||
|
|
||||||
for (const app of secureApps) {
|
for (const app of secureApps) {
|
||||||
// check for labels
|
// check for labels
|
||||||
if (app?.previewLabels.size() > 0) {
|
if (app?.previewLabels && app?.previewLabels?.length > 0) {
|
||||||
let hasLabel: boolean = false;
|
let hasLabel = false;
|
||||||
const labels = githubBody?.pull_request?.labels;
|
const labels = githubBody?.pull_request?.labels;
|
||||||
for (const label of labels) {
|
for (const label of labels) {
|
||||||
if (app?.previewLabels.contains(label.name)) {
|
if (app?.previewLabels?.includes(label.name)) {
|
||||||
hasLabel = true;
|
hasLabel = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -309,6 +309,7 @@ const createSchema = createInsertSchema(applications, {
|
|||||||
previewCertificateType: z.enum(["letsencrypt", "none", "custom"]).optional(),
|
previewCertificateType: z.enum(["letsencrypt", "none", "custom"]).optional(),
|
||||||
previewRequireCollaboratorPermissions: z.boolean().optional(),
|
previewRequireCollaboratorPermissions: z.boolean().optional(),
|
||||||
watchPaths: z.array(z.string()).optional(),
|
watchPaths: z.array(z.string()).optional(),
|
||||||
|
previewLabels: z.array(z.string()).optional(),
|
||||||
cleanCache: z.boolean().optional(),
|
cleanCache: z.boolean().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user