Skip to content

Commit

Permalink
fix(github): use api.github.com for private repository support (#93)
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <pooya@pi0.io>
  • Loading branch information
ishanjain28 and pi0 committed Oct 4, 2023
1 parent 9704865 commit 3d77e59
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@ import { parseGitURI } from "./_utils";

export const github: TemplateProvider = (input, options) => {
const parsed = parseGitURI(input);
const github = process.env.GIGET_GITHUB_URL || "https://github.com";

// https://docs.github.com/en/rest/repos/contents#download-a-repository-archive-tar
// TODO: Verify solution for github enterprise
const githubAPIURL = process.env.GIGET_GITHUB_URL || "https://api.github.com";

return {
name: parsed.repo.replace("/", "-"),
version: parsed.ref,
subdir: parsed.subdir,
headers: {
authorization: options.auth ? `Bearer ${options.auth}` : undefined,
Authorization: options.auth ? `Bearer ${options.auth}` : undefined,
Accept: "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
url: `${github}/${parsed.repo}/tree/${parsed.ref}${parsed.subdir}`,
tar: `${github}/${parsed.repo}/archive/${parsed.ref}.tar.gz`,
url: `${githubAPIURL.replace("api.github.com", "github.com")}/${
parsed.repo
}/tree/${parsed.ref}${parsed.subdir}`,
tar: `${githubAPIURL}/repos/${parsed.repo}/tarball/${parsed.ref}`,
};
};

Expand Down

0 comments on commit 3d77e59

Please sign in to comment.