Functions
decode-content
fn (resource: Map): Str
Decode a contents-API response ({content: base64-with-newlines, encoding: "base64"}) into the file text. Exposed for testing;
get-content applies it.
Example
::github::repos/decode-content({content: "aGVsbG8=\n", encoding: "base64"}) // "hello"
get-content
fn (owner: Str, repo: Str, path: Str): Map
fn (owner: Str, repo: Str, path: Str, opts: Map): Map
fn (owner: Str, repo: Str, path: Str, ref: Str): Map
fn (owner: Str, repo: Str, path: Str, ref: Str, opts: Map): Map
GET /repos/{owner}/{repo}/contents/{path} - Fetch a file and decode
its content. Returns {path, sha, content} where content is the
decoded text — the sha is what put-content needs to update it.
Pass a ref (branch/tag/sha) with the 4-arity Str form. Errs when
path is a directory.
Example
file ::github::repos/get-content("acme", "api", "README.md")
file.content
// From a branch, tag or SHA
tagged ::github::repos/get-content("acme", "api", "VERSION", "v1.2.0")
tagged.sha
get-repo
fn (owner: Str, repo: Str): Map
fn (owner: Str, repo: Str, opts: Map): Map
GET /repos/{owner}/{repo} - Repository metadata (default branch, visibility, topics, counts).
Example
repo ::github::repos/get-repo("acme", "api")
repo.default_branch
list-branches
fn (owner: Str, repo: Str): Vec
fn (owner: Str, repo: Str, params: Map): Vec
fn (owner: Str, repo: Str, params: Map, opts: Map): Vec
GET /repos/{owner}/{repo}/branches - List branches. params supports
per_page, page. Returns a single page (GitHub default 30, max 100);
pass page to paginate.
Example
branches ::github::repos/list-branches("acme", "api", {per_page: 100})
map(branches, %.name)
list-commits
fn (owner: Str, repo: Str): Vec
fn (owner: Str, repo: Str, params: Map): Vec
fn (owner: Str, repo: Str, params: Map, opts: Map): Vec
GET /repos/{owner}/{repo}/commits - List commits, newest first. params
supports sha (branch), path, author, since, until, per_page,
page. Returns a single page (GitHub default 30, max 100); pass page
to paginate.
Example
commits ::github::repos/list-commits("acme", "api", {sha: "main", path: "src", per_page: 20})
map(commits, %.sha)
list-org-repos
fn (org: Str): Vec
fn (org: Str, params: Map): Vec
fn (org: Str, params: Map, opts: Map): Vec
GET /orgs/{org}/repos - List an organization's repositories. params
supports type ("all"/"public"/"private"/"forks"/"sources"/"member"),
sort, per_page, page. Returns a single page (GitHub default 30,
max 100); pass page to paginate.
Example
repos ::github::repos/list-org-repos("acme", {type: "private", per_page: 100})
map(repos, %.name)
list-repos
fn (owner: Str): Vec
fn (owner: Str, params: Map): Vec
fn (owner: Str, params: Map, opts: Map): Vec
GET /users/{owner}/repos - List a user's repositories. params
supports type, sort, per_page, page. Returns a single page
(GitHub default 30, max 100); pass page to paginate. For an
organization's repositories (including private-repo visibility and
org type filters) use list-org-repos.
Example
repos ::github::repos/list-repos("octocat", {sort: "updated", per_page: 10})
map(repos, %.full_name)
put-content
fn (owner: Str, repo: Str, path: Str, options: Map): Map
fn (owner: Str, repo: Str, path: Str, options: Map, opts: Map): Map
PUT /repos/{owner}/{repo}/contents/{path} - Create or update a file
with a commit. options: message (required), content (required,
plain text — encoded automatically), sha (required when updating),
branch.
Example
existing ::github::repos/get-content("acme", "api", "VERSION")
::github::repos/put-content("acme", "api", "VERSION", {
message: "Bump version",
content: "2.0.0",
sha: existing.sha
})