Skip to content
This repository has been archived by the owner on Feb 13, 2022. It is now read-only.

Commit

Permalink
fix: Set branch name for PRs (#1)
Browse files Browse the repository at this point in the history
* fix: Set branch name for PRs

* Remove helper function

Co-Authored-By: Wil Wilsman <wil@percy.io>
  • Loading branch information
Robdel12 and Wil Wilsman authored Dec 5, 2019
1 parent 608b47b commit 376a92d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand All @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand All @@ -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);
Expand Down

0 comments on commit 376a92d

Please sign in to comment.