Skip to content

Commit

Permalink
fix: use head ref for PRs (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-fields authored Jun 17, 2022
1 parent 7c1f2ac commit ef1944e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12707,10 +12707,14 @@ const repoName = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo.repo;
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.info)(`Org: ${repoOrg}`);
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.info)(`Repo: ${repoName}`);
const ref = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.ref;
const headRef = process.env.GITHUB_HEAD_REF;

const getBranch = () => {
if (ref.startsWith("refs/heads/")) {
return ref.substring(11);
} else if (ref.startsWith("refs/pull/") && headRef) {
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.info)(`This is a PR. Using head ref ${headRef} instead of ${ref}`);
return headRef;
}
return ref;
};
Expand Down
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ const repoName = context.repo.repo;
info(`Org: ${repoOrg}`);
info(`Repo: ${repoName}`);
const ref = context.ref;
const headRef = process.env.GITHUB_HEAD_REF;

const getBranch = () => {
if (ref.startsWith("refs/heads/")) {
return ref.substring(11);
} else if (ref.startsWith("refs/pull/") && headRef) {
info(`This is a PR. Using head ref ${headRef} instead of ${ref}`);
return headRef;
}
return ref;
};
Expand Down

0 comments on commit ef1944e

Please sign in to comment.