0
Send information about approved job to channel
One script reply has been approved by the moderators Verified

This script can be used as a flow step that follows approval step

Created by mrl5 761 days ago Viewed 9268 times
0
Submitted by mrl5 Deno
Verified 761 days ago
1
import { WebClient } from "https://deno.land/x/slack_web_api@1.0.0/mod.ts";
2

3
type Slack = {
4
  token: string;
5
};
6
export async function main(channel: string, slack: Slack, approvers: string[]) {
7
  const web = new WebClient(slack.token);
8
  const jobUrl = new URL(
9
    `/run/${Deno.env.get("WM_FLOW_JOB_ID")}`,
10
    Deno.env.get("WM_BASE_URL"),
11
  );
12
  const text = `Flow job ${jobUrl} (${Deno.env.get(
13
    "WM_FLOW_PATH",
14
  )}) run by ${Deno.env.get("WM_USERNAME")} was approved by ${approvers.join(
15
    ", ",
16
  )}`;
17

18
  await web.chat.postMessage({
19
    channel,
20
    text,
21
  });
22
}
23