From f464a66d7753b248b694efe104eb2374d50fd474 Mon Sep 17 00:00:00 2001 From: Ali Garajian Date: Mon, 23 Feb 2026 00:42:09 +0330 Subject: [PATCH 1/2] fix: avoid double npm run commands if build-script is given as input --- src/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 2f0f849..9aa708d 100644 --- a/src/index.js +++ b/src/index.js @@ -46,7 +46,6 @@ async function run(octokit, context, token) { stripHash: stripHash(getInput('strip-hash')) }); - const buildScript = getInput('build-script') || 'build'; const cwd = process.cwd(); let { packageManager, installScript } = await getPackageManagerAndInstallScript(cwd); @@ -54,14 +53,16 @@ async function run(octokit, context, token) { installScript = getInput('install-script'); } + const buildScript = getInput('build-script') || `${packageManager} run build`; + startGroup(`[current] Install Dependencies`); console.log(`Installing using ${installScript}`); await exec(installScript); endGroup(); startGroup(`[current] Build using ${packageManager}`); - console.log(`Building using ${packageManager} run ${buildScript}`); - await exec(`${packageManager} run ${buildScript}`); + console.log(`Building using ${buildScript}`); + await exec(buildScript); endGroup(); // In case the build step alters a JSON-file, .... From 97c4f413ed698212dea86911252325d83f9c3a87 Mon Sep 17 00:00:00 2001 From: Ali Garajian Date: Mon, 23 Feb 2026 00:57:46 +0330 Subject: [PATCH 2/2] fix: use correct error message if base ref is missing --- src/index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 9aa708d..1092f51 100644 --- a/src/index.js +++ b/src/index.js @@ -70,9 +70,19 @@ async function run(octokit, context, token) { const newSizes = await plugin.readFromDisk(cwd); + function throwIfBaseRefMissing() { + if (!baseRef) { + if (context.eventName == 'push') { + throw new Error('missing context.payload.base.ref for push event'); + } else { + throw new Error('missing context.payload.pull_request.base.ref for pull_request event'); + } + } + } + startGroup(`[base] Checkout target branch`); try { - if (!baseRef) throw Error('missing context.payload.pull_request.base.ref'); + throwIfBaseRefMissing(); await exec(`git fetch -n origin ${baseRef}:${baseRef}`); console.log('successfully fetched base.ref'); } catch (e) { @@ -99,7 +109,7 @@ async function run(octokit, context, token) { console.log('checking out and building base commit'); try { - if (!baseRef) throw Error('missing context.payload.base.ref'); + throwIfBaseRefMissing(); await exec(`git reset --hard ${baseRef}`); } catch (e) { await exec(`git reset --hard ${baseSha}`);