Github tana-paste example

This lets you run the script when you are viewing a pull request to prefill some metadata around the pr to paste into Tana

Open tana-github in Script Kit

// Name: tana-github
import "@johnlindquist/kit";
const { Octokit } = await npm("octokit");
const UrlPattern = await npm("url-pattern");
const client = new Octokit({
auth: await env("GITHUB_PULLREQUEST_TOKEN"),
});
const repoPattern = new UrlPattern(
"(http(s)\\://)(:subdomain.):domain.:tld(\\::port)(/:owner)(/:repo)/pull(/:id)"
);
const tab = await getActiveTab("Brave");
const { owner, repo, id } = repoPattern.match(tab);
const res = await client.rest.pulls.get({
owner,
repo,
pull_number: id,
});
const { title, user, html_url } = res.data;
await copy(`%%tana%%
- ${title} #pull request
- Pull Request URL:: ${html_url}
- Github User:: ${user.login}
`);