valToGH

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.

Usage

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);

Parameters

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

Options

  • branch: Optional target branch. Default is main.
  • prefix: Optional directory path prefix for each file.
  • message: Optional commit message. Default is the current date and time in the format yyyy-MM-dd T HH:mm:ss UTC.
  • ts: Optional flag to use a .ts extension for the committed file instead of the default .tsx.