File tree Expand file tree Collapse file tree 1 file changed +28
-4
lines changed
github-actions/create-pr-for-changes/lib Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -92,10 +92,34 @@ 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+ // Rebase PR
113+ git . run ( [ 'checkout' , '-b' , branchName ] ) ;
114+ git . run ( [
115+ 'push' ,
116+ '--force' ,
117+ getRepositoryGitUrl ( forkRepo , git . githubToken ) ,
118+ `HEAD:refs/heads/${ branchName } ` ,
119+ ] ) ;
120+ }
121+ }
122+
99123 return ;
100124 } else {
101125 core . info ( `No pre-existing PR found for branch '${ branchName } '.` ) ;
You can’t perform that action at this time.
0 commit comments