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.
A utility function for programmatically updating a GitHub repository with code retrieved from a Val.
NOTE: This function currently does not change the contents of a file if it is already present. I will however be adding that functionality.
import { valToGH } from 'https://esm.town/v/nbbaier/valToGH';
const repo = "yourGitHubUser/yourRepo";
const val = "valUser/valName"; // or vals = ["valUser/valName1","valUser/valName2", ...]
const ghToken = Deno.env.get("yourGitHubToken");
const result = await valToGH(repo, val, ghToken);
console.log(result);
repo
: The GitHub repository in the format{user}/{repo}
.val
: A single repository in the format{user}/{val}
.ghToken
: Your GitHub token for authentication (must have write permission to the target repo)
branch
: Optional target branch. Default ismain
.prefix
: Optional directory path prefix for each file.message
: Optional commit message. Default is the current date and time in the formatyyyy-MM-dd T HH:mm:ss UTC
.ts
: Optional flag to use a.ts
extension for the committed file instead of the default.tsx
.