diff --git a/dist/index.js b/dist/index.js index 4e7dcce..531883d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8144,7 +8144,6 @@ const ACTION_UA = `${pkg.name}/${pkg.version}`; let workingDir = core.getInput('working-directory'); let outputDir = core.getInput('build-directory'); - let pullRequestNumber = github.context.payload.number; let npxPath = await io.which('npx', true); let execOptions = { cwd: workingDir }; @@ -8160,7 +8159,10 @@ const ACTION_UA = `${pkg.name}/${pkg.version}`; } // Set the PR # (if available) and branch name - !!pullRequestNumber && core.exportVariable('PERCY_PULL_REQUEST', pullRequestNumber); + if (github.context.payload.number) { + core.exportVariable('PERCY_PULL_REQUEST', github.context.payload.number); + core.exportVariable('PERCY_BRANCH', github.context.payload.pull_request.head.ref); + } // Run the passed options with `percy snapshot` to create a Percy build await exec.exec(`"${npxPath}" percy snapshot ${outputDir} ${flags}`, [], execOptions); diff --git a/src/index.js b/src/index.js index 5d52f4d..9f313ed 100644 --- a/src/index.js +++ b/src/index.js @@ -14,7 +14,6 @@ const ACTION_UA = `${pkg.name}/${pkg.version}`; let workingDir = core.getInput('working-directory'); let outputDir = core.getInput('build-directory'); - let pullRequestNumber = github.context.payload.number; let npxPath = await io.which('npx', true); let execOptions = { cwd: workingDir }; @@ -30,7 +29,10 @@ const ACTION_UA = `${pkg.name}/${pkg.version}`; } // Set the PR # (if available) and branch name - !!pullRequestNumber && core.exportVariable('PERCY_PULL_REQUEST', pullRequestNumber); + if (github.context.payload.number) { + core.exportVariable('PERCY_PULL_REQUEST', github.context.payload.number); + core.exportVariable('PERCY_BRANCH', github.context.payload.pull_request.head.ref); + } // Run the passed options with `percy snapshot` to create a Percy build await exec.exec(`"${npxPath}" percy snapshot ${outputDir} ${flags}`, [], execOptions);