Skip to content

Commit

Permalink
Fix is package json version upgraded when branch name contains slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Jan 18, 2022
1 parent 331734f commit efe9b73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12386,7 +12386,10 @@ function action(_actionName, params, core) {
return __awaiter(this, void 0, void 0, function* () {
core.debug(JSON.stringify(params));
const { owner, repo, github_token } = params;
const branch = params.branch.split("/").reverse()[0];
//params.branch <- github.head_ref || github.ref
//When it's a normal branch: github.head_ref==="" and github.ref==="refs/heads/main"
//When it's a pr from: github.head_ref==="<name of the branch branch>"
const branch = params.branch.replace(/^refs\/heads\//, "");
const to_version = yield getPackageJsonVersion({ owner, repo, branch });
if (to_version === undefined) {
throw new Error(`No version in package.json on ${owner}/${repo}#${branch} (or repo is private)`);
Expand Down
5 changes: 4 additions & 1 deletion src/is_package_json_version_upgraded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export async function action(

const { owner, repo, github_token } = params;

const branch = params.branch.split("/").reverse()[0];
//params.branch <- github.head_ref || github.ref
//When it's a normal branch: github.head_ref==="" and github.ref==="refs/heads/main"
//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 });

Expand Down

0 comments on commit efe9b73

Please sign in to comment.