import { Octokit } from "https://cdn.skypack.dev/@octokit/rest";
/**
* @param owner The account owner of the repository. The name is not case sensitive.
*
* @param repo The name of the repository. The name is not case sensitive.
*
* @param path The path to the file or directory.
* If omitted, the contents of the repository's root directory will be returned.
*
* @param ref The name of the commit/branch/tag. Defaults to the default branch of the repository.
*
* @param result_format The kind of data to be returned. This controls how the result is structured.
* Learn more at https://docs.github.com/en/rest/repos/contents#get-repository-content
*/
type Github = {
token: string;
};
export async function main(
gh_auth: Github,
owner: string,
repo: string,
path?: string,
ref?: string,
result_format: "github_object" | "json" = "github_object"
) {
const octokit = new Octokit({ auth: gh_auth.token });
return await octokit.request(
`GET /repos/{owner}/{repo}/contents/{path}${ref ? "?{ref}" : ""}`,
{
owner,
repo,
path,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
Accept: `application/${
result_format === "json" ? "vnd.github+json" : "vnd.github.object"
}`,
},
}
);
}
Submitted by hugo697 396 days ago
import { Octokit } from "https://cdn.skypack.dev/@octokit/rest";
/**
* @param owner The account owner of the repository. The name is not case sensitive.
*
* @param repo The name of the repository. The name is not case sensitive.
*
* @param path The path to the file or directory.
* If omitted, the contents of the repository's root directory will be returned.
*
* @param ref The name of the commit/branch/tag. Defaults to the default branch of the repository.
*
* @param result_format The kind of data to be returned. This controls how the result is structured.
* Learn more at https://docs.github.com/en/rest/repos/contents#get-repository-content
*/
type Github = {
token: string;
};
export async function main(
gh_auth: Github,
owner: string,
repo: string,
path?: string,
ref?: string,
result_format: "github_object" | "json" = "github_object",
) {
const octokit = new Octokit({ auth: gh_auth.token });
return await octokit.request(
`GET /repos/{owner}/{repo}/contents/{path}${ref ? "?{ref}" : ""}`,
{
owner,
repo,
path,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
Accept: `application/${
result_format === "json" ? "vnd.github+json" : "vnd.github.object"
}`,
},
},
);
}
Submitted by admin 469 days ago
import { Octokit } from "https://cdn.skypack.dev/@octokit/rest";
/**
* @param owner The account owner of the repository. The name is not case sensitive.
*
* @param repo The name of the repository. The name is not case sensitive.
*
* @param path The path to the file or directory.
* If omitted, the contents of the repository's root directory will be returned.
*
* @param ref The name of the commit/branch/tag. Defaults to the default branch of the repository.
*
* @param result_format The kind of data to be returned. This controls how the result is structured.
* Learn more at https://docs.github.com/en/rest/repos/contents#get-repository-content
*/
type Github = {
token: string;
};
export async function main(
gh_auth: Github,
owner: string,
repo: string,
path?: string,
ref?: string,
result_format: 'github_object' | 'json' = 'github_object'
) {
const octokit = new Octokit({ auth: gh_auth.token });
return await octokit.request(`GET /repos/{owner}/{repo}/contents/{path}${ref ? '?{ref}' : ''}`, {
owner,
repo,
path,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
Accept: `application/${result_format === 'json' ? 'vnd.github+json' : 'vnd.github.object'}`,
},
});
}
Submitted by admin 472 days ago
import * as wmill from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { Octokit } from "https://cdn.skypack.dev/@octokit/rest";
/**
* @param owner The account owner of the repository. The name is not case sensitive.
*
* @param repo The name of the repository. The name is not case sensitive.
*
* @param path The path to the file or directory.
* If omitted, the contents of the repository's root directory will be returned.
*
* @param ref The name of the commit/branch/tag. Defaults to the default branch of the repository.
*
* @param result_format The kind of data to be returned. This controls how the result is structured.
* Learn more at https://docs.github.com/en/rest/repos/contents#get-repository-content
*/
export async function main(
gh_auth: wmill.Resource<"github">,
owner: string,
repo: string,
path?: string,
ref?: string,
result_format: 'github_object' | 'json' = 'github_object'
) {
const octokit = new Octokit({ auth: gh_auth.token });
return await octokit.request(`GET /repos/{owner}/{repo}/contents/{path}${ref ? '?{ref}' : ''}`, {
owner,
repo,
path,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
Accept: `application/${result_format === 'json' ? 'vnd.github+json' : 'vnd.github.object'}`,
},
});
}
Submitted by adam186 586 days ago