File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed
github-actions/create-pr-for-changes/lib Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -92,10 +92,33 @@ async function main(): Promise<void> {
9292
9393 if ( matchingPrs . length > 0 ) {
9494 // A PR for the same set of changes does already exist. Exit.
95- core . info (
96- `Skipping PR creation, because there is already a PR: #${ matchingPrs [ 0 ] . number } ` +
97- `(${ matchingPrs [ 0 ] . html_url } )` ,
98- ) ;
95+ for ( const matchingPr of matchingPrs ) {
96+ // Check whether there is a PR is conflicting
97+ const {
98+ data : { mergeable} ,
99+ } = await git . github . pulls . get ( {
100+ owner : repo . owner ,
101+ repo : repo . name ,
102+ pull_number : matchingPr . number ,
103+ } ) ;
104+
105+ core . info (
106+ `Skipping PR creation, because there is already a PR: #${ matchingPr . number } ` +
107+ `(${ matchingPr . html_url } )` ,
108+ ) ;
109+
110+ if ( ! mergeable ) {
111+ core . info ( `PR is not mergable, rebasing PR: #${ matchingPr . number } ` ) ;
112+
113+ // Rebase PR
114+ await git . github . pulls . updateBranch ( {
115+ owner : forkRepo . owner ,
116+ repo : forkRepo . name ,
117+ pull_number : matchingPr . number ,
118+ } ) ;
119+ }
120+ }
121+
99122 return ;
100123 } else {
101124 core . info ( `No pre-existing PR found for branch '${ branchName } '.` ) ;
You can’t perform that action at this time.
0 commit comments