mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-05 03:32:16 +00:00
Merge pull request #2952 from spacewaterbear/add_env_in_notifications
feat: display environnement in notification
This commit is contained in:
@@ -19,6 +19,7 @@ export type TemplateProps = {
|
|||||||
applicationType: string;
|
applicationType: string;
|
||||||
buildLink: string;
|
buildLink: string;
|
||||||
date: string;
|
date: string;
|
||||||
|
environmentName: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const BuildSuccessEmail = ({
|
export const BuildSuccessEmail = ({
|
||||||
@@ -27,6 +28,7 @@ export const BuildSuccessEmail = ({
|
|||||||
applicationType = "application",
|
applicationType = "application",
|
||||||
buildLink = "https://dokploy.com/projects/dokploy-test/applications/dokploy-test",
|
buildLink = "https://dokploy.com/projects/dokploy-test/applications/dokploy-test",
|
||||||
date = "2023-05-01T00:00:00.000Z",
|
date = "2023-05-01T00:00:00.000Z",
|
||||||
|
environmentName = "production",
|
||||||
}: TemplateProps) => {
|
}: TemplateProps) => {
|
||||||
const previewText = `Build success for ${applicationName}`;
|
const previewText = `Build success for ${applicationName}`;
|
||||||
return (
|
return (
|
||||||
@@ -74,6 +76,9 @@ export const BuildSuccessEmail = ({
|
|||||||
<Text className="!leading-3">
|
<Text className="!leading-3">
|
||||||
Application Name: <strong>{applicationName}</strong>
|
Application Name: <strong>{applicationName}</strong>
|
||||||
</Text>
|
</Text>
|
||||||
|
<Text className="!leading-3">
|
||||||
|
Environment: <strong>{environmentName}</strong>
|
||||||
|
</Text>
|
||||||
<Text className="!leading-3">
|
<Text className="!leading-3">
|
||||||
Application Type: <strong>{applicationType}</strong>
|
Application Type: <strong>{applicationType}</strong>
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ export const deployApplication = async ({
|
|||||||
buildLink,
|
buildLink,
|
||||||
organizationId: application.environment.project.organizationId,
|
organizationId: application.environment.project.organizationId,
|
||||||
domains: application.domains,
|
domains: application.domains,
|
||||||
|
environmentName: application.environment.name,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const command = `echo "Error occurred ❌, check the logs for details." >> ${deployment.logPath};`;
|
const command = `echo "Error occurred ❌, check the logs for details." >> ${deployment.logPath};`;
|
||||||
@@ -273,6 +274,7 @@ export const rebuildApplication = async ({
|
|||||||
descriptionLog: string;
|
descriptionLog: string;
|
||||||
}) => {
|
}) => {
|
||||||
const application = await findApplicationById(applicationId);
|
const application = await findApplicationById(applicationId);
|
||||||
|
const buildLink = `${await getDokployUrl()}/dashboard/project/${application.environment.projectId}/environment/${application.environmentId}/services/application/${application.applicationId}?tab=deployments`;
|
||||||
|
|
||||||
const deployment = await createDeployment({
|
const deployment = await createDeployment({
|
||||||
applicationId: applicationId,
|
applicationId: applicationId,
|
||||||
@@ -293,6 +295,27 @@ export const rebuildApplication = async ({
|
|||||||
await mechanizeDockerContainer(application);
|
await mechanizeDockerContainer(application);
|
||||||
await updateDeploymentStatus(deployment.deploymentId, "done");
|
await updateDeploymentStatus(deployment.deploymentId, "done");
|
||||||
await updateApplicationStatus(applicationId, "done");
|
await updateApplicationStatus(applicationId, "done");
|
||||||
|
|
||||||
|
if (application.rollbackActive) {
|
||||||
|
const tagImage =
|
||||||
|
application.sourceType === "docker"
|
||||||
|
? application.dockerImage
|
||||||
|
: application.appName;
|
||||||
|
await createRollback({
|
||||||
|
appName: tagImage || "",
|
||||||
|
deploymentId: deployment.deploymentId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await sendBuildSuccessNotifications({
|
||||||
|
projectName: application.environment.project.name,
|
||||||
|
applicationName: application.name,
|
||||||
|
applicationType: "application",
|
||||||
|
buildLink,
|
||||||
|
organizationId: application.environment.project.organizationId,
|
||||||
|
domains: application.domains,
|
||||||
|
environmentName: application.environment.name,
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await updateDeploymentStatus(deployment.deploymentId, "error");
|
await updateDeploymentStatus(deployment.deploymentId, "error");
|
||||||
await updateApplicationStatus(applicationId, "error");
|
await updateApplicationStatus(applicationId, "error");
|
||||||
|
|||||||
@@ -267,6 +267,7 @@ export const deployCompose = async ({
|
|||||||
buildLink,
|
buildLink,
|
||||||
organizationId: compose.environment.project.organizationId,
|
organizationId: compose.environment.project.organizationId,
|
||||||
domains: compose.domains,
|
domains: compose.domains,
|
||||||
|
environmentName: compose.environment.name,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await updateDeploymentStatus(deployment.deploymentId, "error");
|
await updateDeploymentStatus(deployment.deploymentId, "error");
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ interface Props {
|
|||||||
buildLink: string;
|
buildLink: string;
|
||||||
organizationId: string;
|
organizationId: string;
|
||||||
domains: Domain[];
|
domains: Domain[];
|
||||||
|
environmentName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sendBuildSuccessNotifications = async ({
|
export const sendBuildSuccessNotifications = async ({
|
||||||
@@ -31,6 +32,7 @@ export const sendBuildSuccessNotifications = async ({
|
|||||||
buildLink,
|
buildLink,
|
||||||
organizationId,
|
organizationId,
|
||||||
domains,
|
domains,
|
||||||
|
environmentName,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const unixDate = ~~(Number(date) / 1000);
|
const unixDate = ~~(Number(date) / 1000);
|
||||||
@@ -62,6 +64,7 @@ export const sendBuildSuccessNotifications = async ({
|
|||||||
applicationType,
|
applicationType,
|
||||||
buildLink,
|
buildLink,
|
||||||
date: date.toLocaleString(),
|
date: date.toLocaleString(),
|
||||||
|
environmentName,
|
||||||
}),
|
}),
|
||||||
).catch();
|
).catch();
|
||||||
await sendEmailNotification(email, "Build success for dokploy", template);
|
await sendEmailNotification(email, "Build success for dokploy", template);
|
||||||
@@ -72,7 +75,7 @@ export const sendBuildSuccessNotifications = async ({
|
|||||||
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
||||||
|
|
||||||
await sendDiscordNotification(discord, {
|
await sendDiscordNotification(discord, {
|
||||||
title: decorate(">", "`✅` Build Success"),
|
title: decorate(">", "`✅` Build Successes"),
|
||||||
color: 0x57f287,
|
color: 0x57f287,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@@ -85,6 +88,11 @@ export const sendBuildSuccessNotifications = async ({
|
|||||||
value: applicationName,
|
value: applicationName,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: decorate("`🌍`", "Environment"),
|
||||||
|
value: environmentName,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: decorate("`❔`", "Type"),
|
name: decorate("`❔`", "Type"),
|
||||||
value: applicationType,
|
value: applicationType,
|
||||||
@@ -125,6 +133,7 @@ export const sendBuildSuccessNotifications = async ({
|
|||||||
decorate("✅", "Build Success"),
|
decorate("✅", "Build Success"),
|
||||||
`${decorate("🛠️", `Project: ${projectName}`)}` +
|
`${decorate("🛠️", `Project: ${projectName}`)}` +
|
||||||
`${decorate("⚙️", `Application: ${applicationName}`)}` +
|
`${decorate("⚙️", `Application: ${applicationName}`)}` +
|
||||||
|
`${decorate("🌍", `Environment: ${environmentName}`)}` +
|
||||||
`${decorate("❔", `Type: ${applicationType}`)}` +
|
`${decorate("❔", `Type: ${applicationType}`)}` +
|
||||||
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
`${decorate("🕒", `Date: ${date.toLocaleString()}`)}` +
|
||||||
`${decorate("🔗", `Build details:\n${buildLink}`)}`,
|
`${decorate("🔗", `Build details:\n${buildLink}`)}`,
|
||||||
@@ -139,6 +148,7 @@ export const sendBuildSuccessNotifications = async ({
|
|||||||
`view, Build details, ${buildLink}, clear=true;`,
|
`view, Build details, ${buildLink}, clear=true;`,
|
||||||
`🛠Project: ${projectName}\n` +
|
`🛠Project: ${projectName}\n` +
|
||||||
`⚙️Application: ${applicationName}\n` +
|
`⚙️Application: ${applicationName}\n` +
|
||||||
|
`🌍Environment: ${environmentName}\n` +
|
||||||
`❔Type: ${applicationType}\n` +
|
`❔Type: ${applicationType}\n` +
|
||||||
`🕒Date: ${date.toLocaleString()}`,
|
`🕒Date: ${date.toLocaleString()}`,
|
||||||
);
|
);
|
||||||
@@ -167,7 +177,7 @@ export const sendBuildSuccessNotifications = async ({
|
|||||||
|
|
||||||
await sendTelegramNotification(
|
await sendTelegramNotification(
|
||||||
telegram,
|
telegram,
|
||||||
`<b>✅ Build Success</b>\n\n<b>Project:</b> ${projectName}\n<b>Application:</b> ${applicationName}\n<b>Type:</b> ${applicationType}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}`,
|
`<b>✅ Build Success</b>\n\n<b>Project:</b> ${projectName}\n<b>Application:</b> ${applicationName}\n<b>Environment:</b> ${environmentName}\n<b>Type:</b> ${applicationType}\n<b>Date:</b> ${format(date, "PP")}\n<b>Time:</b> ${format(date, "pp")}`,
|
||||||
inlineButton,
|
inlineButton,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -191,6 +201,11 @@ export const sendBuildSuccessNotifications = async ({
|
|||||||
value: applicationName,
|
value: applicationName,
|
||||||
short: true,
|
short: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "Environment",
|
||||||
|
value: environmentName,
|
||||||
|
short: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Type",
|
title: "Type",
|
||||||
value: applicationType,
|
value: applicationType,
|
||||||
@@ -260,6 +275,12 @@ export const sendBuildSuccessNotifications = async ({
|
|||||||
text_align: "left",
|
text_align: "left",
|
||||||
text_size: "normal_v2",
|
text_size: "normal_v2",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
tag: "markdown",
|
||||||
|
content: `**Environment:**\n${environmentName}`,
|
||||||
|
text_align: "left",
|
||||||
|
text_size: "normal_v2",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
tag: "markdown",
|
tag: "markdown",
|
||||||
content: `**Type:**\n${applicationType}`,
|
content: `**Type:**\n${applicationType}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user