Readme

Stale GitHub PRs email

This val is designed to identify and report stale pull requests (PRs) across specified GitHub repositories. It checks for PRs that haven't had any activity for a predefined number of days (default is 3 days) and sends an email summary of these PRs. The email contains details formatted in HTML, offering an overview of PRs requiring attention.

Usage

  1. Fork this val;
  2. Add the following environment variables:
    • githubRepos: comma separated list of repos to check
    • github: GitHub token
    • githubOwner: Owner name
Runs every 1 days
Fork
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
26
27
28
29
30
31
32
33
34
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";
// 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 = Deno.env.get("githubRepos")?.split(",").filter((r) => r.trim()) ?? [];
if (!repos.length) {
console.log("No GitHub repos being checked");
return;
}
let staleSinceDaysAgo = 3; // Any PR with no activity for this many days will qualify
let pullRequests = await reposStaleGithubPRs(
repos,
Deno.env.get("githubOwner"), // Set up a secret named githubOwner with the owner name
Deno.env.get("github"), // Create GitHub token and set up this secret
staleSinceDaysAgo,
);
if (!repos.length) {
console.log("No stale PRs");
return;
}
let { html, subject } = prsEmail(
pullRequests,
staleSinceDaysAgo,
);
await email({
html,
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.