1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { prsEmail } from "https://esm.town/v/ramkarthik/prsEmail";
import { reposStaleGithubPRs } from "https://esm.town/v/ramkarthik/reposStaleGithubPRs";
import process from "node:process";
// Sends an email with all the open PRs that have not had any activity
// for specified period of days
// Set up this function to run every day (or any interval)
export async function staleGithubPRsEmail() {
// Set up a secret named githubRepos with all the repos you want to analyze (comma separated)
let repos = process.env.githubRepos.split(",").filter((r) =>
r.trim()
);
let staleSinceDaysAgo = 3; // Any PR with no activity for this many days will qualify
let pullRequests = await reposStaleGithubPRs(
repos,
process.env.githubOwner, // Set up a secret named githubOwner with the owner name
process.env.github, // Create GitHub token and set up this secret
staleSinceDaysAgo,
);
let { html, subject } = prsEmail(
pullRequests,
staleSinceDaysAgo,
);
console.email({ html: html, subject: subject });
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.