Skip to content

Commit

Permalink
Merge pull request #18 from donaldwasserman/master
Browse files Browse the repository at this point in the history
Provide fallback PR branch in some cases
  • Loading branch information
donaldwasserman authored May 18, 2020
2 parents 8db8653 + 3edcef6 commit 85a47ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ async function run() {
changelogExists = false;
}

let { url, tag, name, body, releaseBranch } = getReleaseData(eventPath);
let { url, tag, name, body, releaseBranch, repoDefaultBranch } = getReleaseData(
eventPath
);

let branch = defaultBranch || releaseBranch;

Expand All @@ -559,6 +561,10 @@ async function run() {

let prBranch = core.getInput('branch_name') || `changelog-${tag}`;

if (!prBranch) {
prBranch = repoDefaultBranch;
}

if (usePr) {
let refSha;
try {
Expand Down Expand Up @@ -618,7 +624,8 @@ function getReleaseData(eventPath) {
target_commitish: releaseBranch
} = event.release;

return { url, tag, name, body, releaseBranch };
let { default_branch: repoDefaultBranch } = event.repository;
return { url, tag, name, body, releaseBranch, repoDefaultBranch };
}

run();
Expand Down
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ async function run() {
changelogExists = false;
}

let { url, tag, name, body, releaseBranch } = getReleaseData(eventPath);
let { url, tag, name, body, releaseBranch, repoDefaultBranch } = getReleaseData(
eventPath
);

let branch = defaultBranch || releaseBranch;

Expand All @@ -65,6 +67,10 @@ async function run() {

let prBranch = core.getInput('branch_name') || `changelog-${tag}`;

if (!prBranch) {
prBranch = repoDefaultBranch;
}

if (usePr) {
let refSha;
try {
Expand Down Expand Up @@ -124,7 +130,8 @@ function getReleaseData(eventPath) {
target_commitish: releaseBranch
} = event.release;

return { url, tag, name, body, releaseBranch };
let { default_branch: repoDefaultBranch } = event.repository;
return { url, tag, name, body, releaseBranch, repoDefaultBranch };
}

run();

0 comments on commit 85a47ed

Please sign in to comment.