Public
Cron
Forked from andreterron/staleGithubPRsEmail
Runs every 1 days
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,
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
June 16, 2024