Skip to content
Merged
Show file tree
Hide file tree
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
32 changes: 28 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,34 @@ 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 branch: #${branchName}`);
// Push the local branch to update the target branch (already rebased)
git.run(['checkout', '-b', branchName]);
git.run([
'push',
'--force-with-lease',
getRepositoryGitUrl(forkRepo, git.githubToken),
`HEAD:refs/heads/${branchName}`,
]);
}
}

return;
} else {
core.info(`No pre-existing PR found for branch '${branchName}'.`);
Expand Down
19 changes: 18 additions & 1 deletion github-actions/create-pr-for-changes/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47972,7 +47972,24 @@ async function main() {
state: "open"
});
if (matchingPrs.length > 0) {
core.info(`Skipping PR creation, because there is already a PR: #${matchingPrs[0].number} (${matchingPrs[0].html_url})`);
for (const matchingPr of matchingPrs) {
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 branch: #${branchName}`);
git.run(["checkout", "-b", branchName]);
git.run([
"push",
"--force-with-lease",
getRepositoryGitUrl(forkRepo, git.githubToken),
`HEAD:refs/heads/${branchName}`
]);
}
}
return;
} else {
core.info(`No pre-existing PR found for branch '${branchName}'.`);
Expand Down