A scheduled Val Town cron script that monitors a GitHub repository for issues updated since the last run. It fetches updated issues using the GitHub API, logs their details, and tracks the last run timestamp using Val Town's SQLite integration.
Set the following environment variables in your Val Town project:
GITHUB_TOKEN – A GitHub personal access token with repo access (for private repos) or public_repo (for public repos).GITHUB_REPO_OWNER – The owner (user or org) of the repository to monitor.GITHUB_REPO_NAME – The name of the repository to monitor.You can also pass these as options to the exported functions if you prefer not to use environment variables.
Ensure your GitHub token has the correct permissions to read issues from the target repository.
This val is a cron trigger. It will run automatically on the schedule you set in Val Town. On each run, it:
You can also invoke the main function manually for testing:
import monitorGitHubIssues from "./github-issues-monitor.cron.tsx";
await monitorGitHubIssues();
Or use the helper to fetch issues directly:
import { getGitHubIssuesUpdatedSinceLastRun } from "./github-issues-monitor.cron.tsx";
const issues = await getGitHubIssuesUpdatedSinceLastRun();
You can monitor a different repository or use a different token by passing options:
await monitorGitHubIssues({
repoOwner: "octocat",
repoName: "Hello-World",
githubToken: "ghp_..."
});
github-issues-monitor.cron.tsx.monitorGitHubIssues function.MIT (or specify your preferred license)