Skip to content

Commit

Permalink
Make is_package_json_version_upgraded work with private repos
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Jun 20, 2024
1 parent 45686f5 commit 9356720
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/is_package_json_version_upgraded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function action(
//When it's a pr from: github.head_ref==="<name of the branch branch>"
const branch = params.branch.replace(/^refs\/heads\//, "");

const to_version = await getPackageJsonVersion({ owner, repo, branch });
const to_version = await getPackageJsonVersion({ owner, repo, branch, github_token });

if( to_version === undefined ){
throw new Error(`No version in package.json on ${owner}/${repo}#${branch} (or repo is private)`);
Expand Down Expand Up @@ -107,9 +107,10 @@ async function getPackageJsonVersion(params: {
owner: string;
repo: string;
branch: string;
github_token: string;
}): Promise<NpmModuleVersion | undefined> {

const { owner, repo, branch } = params;
const { owner, repo, branch, github_token } = params;

const version = await fetch(
urlJoin(
Expand All @@ -118,7 +119,12 @@ async function getPackageJsonVersion(params: {
repo,
branch,
"package.json"
)
),
{
"headers": {
"Authorization": `token ${github_token}`
}
}
)
.then(res => res.text())
.then(text => JSON.parse(text))
Expand Down

0 comments on commit 9356720

Please sign in to comment.