Skip to content

Commit

Permalink
fix: create pull request if branch exists but there is no open PR
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Nov 22, 2019
1 parent 23647a6 commit a98dca9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,17 @@ async function main() {
);

if (remoteBranchExists) {
core.info(`Existing pull request for "${inputs.branch}" updated`);
return;
const q = `head:${inputs.branch} type:pr is:open repo:${process.env.GITHUB_REPOSITORY}`;
const { data } = await request("GET /search/issues", {
q
});

if (data.total_count > 0) {
core.info(
`Existing pull request for branch "${inputs.branch}" updated: ${data.items.html_url}`
);
return;
}
}

core.debug(`Creating pull request`);
Expand Down

0 comments on commit a98dca9

Please sign in to comment.