Github API examples & templates
Use these vals as a playground to view and fork Github API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
yawnxyz
selectHtml
Script
SelectHtml is a Deno-based HTML scraper that integrates AI with Cheerio and Pug. This tool allows you to fetch, clean, and manipulate HTML content from URLs, using the Cheerio library to select and clean the HTML elements, and html2pug to convert HTML into Pug templates. Deprecated; use htmlTo instead, as that one supports more formats: https://www.val.town/v/yawnxyz/htmlTo
0
tmcw
devstats
HTTP
Developer Statistics This val lets you post statistics from your GitHub Actions runs to build charts of change over time. We do this by having a step at the end of our actions run like this: - name: devstats
run: |
curl -X "POST" "https://tmcw-devstats.web.val.run/" \
-H 'Authorization: Bearer ${{ secrets.DEVSTATS_TOKEN }}' \
-H 'Content-Type: application/json; charset=utf-8' \
-d $"{ \"name\": \"node_modules_kb\", \"value\": $(du -sk node_modules | awk '{print $1}') }" And setting a DEVSTATS_TOKEN value, which could be any short random value, both in Val Town environment variables
and as a secret in your GitHub Actions configuration. Currently the name you attach to a statistic can be anything, and the value is expected to be a number.
4
nbbaier
submitPR
Script
Submit a PR from Val Town This val provides a (very) thin wrapper around the GH rest API methods for creating a pull request. It handles the creation of a Octokit client for you. Usage import { submitPR } from "https://esm.town/v/nbbaier/submitPR";
await submitPR(Deno.env.get("GH_REPO_TOKEN"), {
owner: "nbbaier",
repo: "test-ground",
head: "branch_2",
base: "main",
title: "trying another PR",
body: "cool stuff, take a look",
}); Parameters The function takes two parameters: your gh access token and an object that's identical to the object submitted to the gh API. See GH's documentation for more info!
0
fil
beckerBarley
HTTP
Becker’s Barley trellis SSR chart with Observable Plot This chart is rendered server-side by val.town, using Observable Plot, from data loaded from the GitHub API. For a more complete example, see https://www.val.town/v/fil.earthquakes. For information on this chart, see https://observablehq.com/@observablehq/plot-barley-trellis.
6