Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions github-actions/create-pr-for-changes/lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,33 @@ async function main(): Promise<void> {

if (matchingPrs.length > 0) {
// A PR for the same set of changes does already exist. Exit.
core.info(
`Skipping PR creation, because there is already a PR: #${matchingPrs[0].number} ` +
`(${matchingPrs[0].html_url})`,
);
for (const matchingPr of matchingPrs) {
// Check whether there is a PR is conflicting
const {
data: {mergeable},
} = await git.github.pulls.get({
owner: repo.owner,
repo: repo.name,
pull_number: matchingPr.number,
});

core.info(
`Skipping PR creation, because there is already a PR: #${matchingPr.number} ` +
`(${matchingPr.html_url})`,
);

if (!mergeable) {
core.info(`PR is not mergable, rebasing PR: #${matchingPr.number}`);

// Rebase PR
await git.github.pulls.updateBranch({
owner: forkRepo.owner,
repo: forkRepo.name,
pull_number: matchingPr.number,
});
}
}

return;
} else {
core.info(`No pre-existing PR found for branch '${branchName}'.`);
Expand Down
Loading