import { prsEmail } from "https://esm.town/v/ramkarthik/prsEmail?v=2";
import { reposStaleGithubPRs } from "https://esm.town/v/ramkarthik/reposStaleGithubPRs?v=1";
import { email } from "https://esm.town/v/std/email?v=11";
export async function staleGithubPRsEmail() {
let repos = Deno.env.get("githubRepos")?.split(",").filter((r) => r.trim()) ?? [];
if (!repos.length) {
console.log("No GitHub repos being checked");
return;
}
let staleSinceDaysAgo = 3;
let pullRequests = await reposStaleGithubPRs(
repos,
Deno.env.get("githubOwner"),
Deno.env.get("github"),
staleSinceDaysAgo,
);
if (!repos.length) {
console.log("No stale PRs");
return;
}
let { html, subject } = prsEmail(
pullRequests,
staleSinceDaysAgo,
);
await email({
html,
subject,
});
}