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.
- Scheduled Monitoring: Runs on a schedule (cron trigger) to check for updated issues in a specified GitHub repository.
- Efficient Tracking: Only fetches issues updated since the last run, minimizing API calls.
- Persistent State: Stores the last run timestamp in Val Town SQLite.
- Customizable: Easily configure which repository to monitor and which GitHub token to use.
- TypeScript: Fully typed, modern ES6+ code.
Set the following environment variables in your Val Town project:
GITHUB_TOKEN
– A GitHub personal access token withrepo
access (for private repos) orpublic_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:
- Loads the last run timestamp from SQLite (or defaults to 24 hours ago if first run).
- Fetches all issues updated since that timestamp from the configured GitHub repository.
- Logs details about each updated issue (number, title, state, author, URL, etc.).
- Updates the last run timestamp in SQLite.
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_..."
});
- Uses Val Town's SQLite integration for persistent state.
- Requires environment variables for secrets (never hardcode tokens).
- Designed for Deno/Val Town serverless context.
- Follows Val Town best practices for cron triggers and error handling.
- All code is in
github-issues-monitor.cron.tsx
. - TypeScript interfaces are provided for clarity and type safety.
- To extend functionality (e.g., notifications, filtering), modify the
monitorGitHubIssues
function.
MIT (or specify your preferred license)