This script can be used as a flow step that follows approval step
1
import { WebClient } from "https://deno.land/x/[email protected]/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