FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
cricks_unmixed4u
cricks_unmixed4ugithub-api
Public
Like
github-api
Home
Code
6
.vtignore
README.md
deno.json
S
github-issues-monitor.cron.tsx
knowledge.md
S
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
3
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
Sign up now
Code
/
Code
/
Search
README.md

GitHub Issues Monitor (Val Town)

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.

Features

  • 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.

Setup

1. Environment Variables

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.

2. Permissions

Ensure your GitHub token has the correct permissions to read issues from the target repository.

Usage

This val is a cron trigger. It will run automatically on the schedule you set in Val Town. On each run, it:

  1. Loads the last run timestamp from SQLite (or defaults to 24 hours ago if first run).
  2. Fetches all issues updated since that timestamp from the configured GitHub repository.
  3. Logs details about each updated issue (number, title, state, author, URL, etc.).
  4. Updates the last run timestamp in SQLite.

Manual Execution

You can also invoke the main function manually for testing:

Create val
import monitorGitHubIssues from "./github-issues-monitor.cron.tsx"; await monitorGitHubIssues();

Or use the helper to fetch issues directly:

Create val
import { getGitHubIssuesUpdatedSinceLastRun } from "./github-issues-monitor.cron.tsx"; const issues = await getGitHubIssuesUpdatedSinceLastRun();

Customization

You can monitor a different repository or use a different token by passing options:

Create val
await monitorGitHubIssues({ repoOwner: "octocat", repoName: "Hello-World", githubToken: "ghp_..." });

Val Town Platform Notes

  • 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.

Development

  • 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.

License

MIT (or specify your preferred license)

Code
.vtignoreREADME.mddeno.json
S
github-issues-monitor.cron.tsx
knowledge.md
S
main.tsx
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.