GitHub ⇄ Beeminder Sync
Synchronise GitHub issue activity with a Beeminder goal using Val Town.
⸻
What this val does • Tracks issues or pull-requests updated in a chosen GitHub repository since the last run. • Sends the resulting metric (count, estimate of effort, etc.) to a Beeminder goal, keeping your graph up to date automatically. • Runs entirely inside Val Town on a schedule you control—no external servers or manual scripts.
It relies on two helper vals already published to Val Town:
Val Purpose github-api Provides a convenient wrapper around GitHub’s REST API, including a helper to fetch issues updated since the previous execution. beeminder-client Minimal client for Beeminder’s v1 API, covering goal lookup and datapoint creation.
⸻
Prerequisites 1. Val Town account with Cron permissions. 2. GitHub Personal Access Token (classic PAT or fine-grained) with at least repo:read scope for the target repository. 3. Beeminder Auth Token (find it under Account → Settings → API token). 4. A Beeminder goal ready to receive datapoints (e.g. a do-more goal counting issues closed per day).
⸻
Setup in 3 steps 1. Copy the val Open this val in Val Town and press Copy (top-right). This creates an editable copy under your namespace. 2. Add environment variables Go to Account → Secrets, then add: • GITHUB_TOKEN – your PAT. • GITHUB_REPO – in owner/repo format (e.g. octo-org/monorepo). • BEEMINDER_USERNAME – your Beeminder username. • BEEMINDER_TOKEN – your Beeminder auth token. • BEEMINDER_GOAL – the slug of the goal to update (case-sensitive). 3. Schedule the job In the editor pane, click Schedule → Cron and choose how often it should run—hourly is typical (0 * * * *). The val keeps internal state to avoid double-counting, so any frequency works.
That’s it! The next time the schedule fires, your Beeminder graph will reflect fresh GitHub activity automatically.
⸻
How it works (high-level) 1. Determine time window using Val Town’s built-in meta.lastRunAt. 2. Fetch recent issues/PRs via github-api helper. 3. Compute datapoint value (default: number of items; tweakable). 4. POST to Beeminder with timestamp and an optional comment summarising the items.
Each run logs its actions to Val Town’s output console so you can audit behaviour.
⸻
Customising the behaviour • Filter logic – adjust the helper call to narrow by label, assignee, or PR v. issue. • Datapoint format – modify the comment template or map effort scores instead of raw counts. • Multiple goals – call the Beeminder client twice if you want separate graphs for issues opened versus closed.
Because everything is plain TypeScript inside Val Town, any tweak is just a few lines.
⸻
Troubleshooting
Symptom Likely cause 401 Unauthorized from GitHub Expired or missing GITHUB_TOKEN. No datapoints appearing Wrong BEEMINDER_GOAL slug, or schedule hasn’t triggered yet. Duplicate datapoints Schedule overlaps (e.g. running twice a minute). Use a coarser cron pattern.
Check the Run History tab in Val Town for full logs.
⸻
License
MIT – feel free to adapt and extend.