import { WebClient } from '@slack/web-api';
import dayjs from "dayjs";
type Slack = {
token: string;
};
export async function main(
path: string, // The path of the script or flow
is_flow: boolean, // Whether the runnable is a flow
schedule_path: string, // The path of the schedule
success_result: object, // The result of the latest successful job
success_started_at: string, // The start datetime of the latest successful job
slack: Slack,
channel: string,
) {
const baseUrl = process.env["WM_BASE_URL"];
const scheduleUrl = baseUrl + "/runs?schedule_path=" +
encodeURIComponent(schedule_path);
const runnableUrl = baseUrl + (is_flow ? "/flows/get/" : "/scripts/get/") +
path;
const web = new WebClient(slack.token);
await web.chat.postMessage({
channel,
text: `Schedule ${schedule_path} was successful`,
blocks: [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": `*Schedule <${scheduleUrl}|${schedule_path}> was successful*:\n- ${is_flow ? "Flow" : "Script"}: <${runnableUrl}|${path}>`,
},
},
],
attachments: [
{
color: "#00ff00",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": `Started at: ${dayjs(success_started_at).format("DD.MM.YYYY HH:mm (Z)")
}\n\`\`\`\n${JSON.stringify(success_result)}\n\`\`\``,
},
},
],
},
],
});
}
Submitted by rubenfiszel 67 days ago
import { WebClient } from '@slack/web-api';
import dayjs from "dayjs";
type Slack = {
token: string;
};
export async function main(
path: string, // The path of the script or flow
is_flow: boolean, // Whether the runnable is a flow
schedule_path: string, // The path of the schedule
success_result: object, // The result of the latest successful job
success_started_at: string, // The start datetime of the latest successful job
slack: Slack,
channel: string,
) {
const baseUrl = process.env["WM_BASE_URL"];
const scheduleUrl = baseUrl + "/runs?schedule_path=" +
encodeURIComponent(schedule_path);
const runnableUrl = baseUrl + (is_flow ? "/flows/get/" : "/scripts/get/") +
path;
const web = new WebClient(slack.token);
await web.chat.postMessage({
channel,
text: `Schedule ${schedule_path} was successful`,
blocks: [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": `*Schedule <${scheduleUrl}|${schedule_path}> was successful*:\n- ${is_flow ? "Flow" : "Script"}: <${runnableUrl}|${path}>`,
},
},
],
attachments: [
{
color: "#00ff00",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": `Started at: ${dayjs(success_started_at).format("DD.MM.YYYY HH:mm (Z)")
}\n\`\`\`\n${JSON.stringify(success_result)}\n\`\`\``,
},
},
],
},
],
});
}
Submitted by hugo697 70 days ago
import { WebClient } from '@slack/web-api';
import dayjs from "dayjs";
type Slack = {
token: string;
};
export async function main(
path: string, // The path of the script or flow that errored
is_flow: boolean, // Whether the runnable is a flow
schedule_path: string, // The path of the schedule
success_result: object, // The result of the latest successful job
success_started_at: string, // The start datetime of the latest successful job
slack: Slack,
channel: string,
) {
const baseUrl = process.env["WM_BASE_URL"];
const scheduleUrl = baseUrl + "/runs?schedule_path=" +
encodeURIComponent(schedule_path);
const runnableUrl = baseUrl + (is_flow ? "/flows/get/" : "/scripts/get/") +
path;
const web = new WebClient(slack.token);
await web.chat.postMessage({
channel,
text: `Schedule ${schedule_path} was successful`,
blocks: [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": `*Schedule <${scheduleUrl}|${schedule_path}> was successful*:\n- ${is_flow ? "Flow" : "Script"}: <${runnableUrl}|${path}>`,
},
},
],
attachments: [
{
color: "#00ff00",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": `Started at: ${dayjs(success_started_at).format("DD.MM.YYYY HH:mm (Z)")
}\n\`\`\`\n${JSON.stringify(success_result)}\n\`\`\``,
},
},
],
},
],
});
}
Submitted by hugo697 70 days ago