@@ -450,6 +450,7 @@ export const backportImpl = async (
450
450
pr : WebHookPR ,
451
451
targetBranch : string ,
452
452
purpose : BackportPurpose ,
453
+ checkRun : NonNullable < Awaited < ReturnType < typeof getCheckRun > > > ,
453
454
labelToRemove ?: string ,
454
455
labelToAdd ?: string ,
455
456
) => {
@@ -485,16 +486,13 @@ export const backportImpl = async (
485
486
`backport-${ pr . head . sha } -${ targetBranch } -${ purpose } ` ,
486
487
async ( ) => {
487
488
log ( 'backportImpl' , LogLevel . INFO , `Executing ${ bp } for "${ slug } "` ) ;
488
- const checkRun = await getCheckRun ( context , pr , targetBranch ) ;
489
- if ( checkRun ) {
490
- await context . octokit . checks . update (
491
- context . repo ( {
492
- check_run_id : checkRun . id ,
493
- name : checkRun . name ,
494
- status : 'in_progress' as 'in_progress' ,
495
- } ) ,
496
- ) ;
497
- }
489
+ await context . octokit . checks . update (
490
+ context . repo ( {
491
+ check_run_id : checkRun . id ,
492
+ name : checkRun . name ,
493
+ status : 'in_progress' as 'in_progress' ,
494
+ } ) ,
495
+ ) ;
498
496
499
497
const repoAccessToken = await getRepoToken ( robot , context ) ;
500
498
@@ -679,20 +677,18 @@ export const backportImpl = async (
679
677
log ( 'backportImpl' , LogLevel . INFO , 'Backport process complete' ) ;
680
678
}
681
679
682
- if ( checkRun ) {
683
- context . octokit . checks . update (
684
- context . repo ( {
685
- check_run_id : checkRun . id ,
686
- name : checkRun . name ,
687
- conclusion : 'success' as 'success' ,
688
- completed_at : new Date ( ) . toISOString ( ) ,
689
- output : {
690
- title : 'Clean Backport' ,
691
- summary : `This PR was checked and can be backported to "${ targetBranch } " cleanly.` ,
692
- } ,
693
- } ) ,
694
- ) ;
695
- }
680
+ context . octokit . checks . update (
681
+ context . repo ( {
682
+ check_run_id : checkRun . id ,
683
+ name : checkRun . name ,
684
+ conclusion : 'success' as 'success' ,
685
+ completed_at : new Date ( ) . toISOString ( ) ,
686
+ output : {
687
+ title : 'Clean Backport' ,
688
+ summary : `This PR was checked and can be backported to "${ targetBranch } " cleanly.` ,
689
+ } ,
690
+ } ) ,
691
+ ) ;
696
692
697
693
await fs . remove ( createdDir ) ;
698
694
} ,
@@ -759,30 +755,27 @@ export const backportImpl = async (
759
755
] ) ;
760
756
}
761
757
762
- const checkRun = await getCheckRun ( context , pr , targetBranch ) ;
763
- if ( checkRun ) {
764
- const mdSep = '``````````````````````````````' ;
765
- const updateOpts = context . repo ( {
766
- check_run_id : checkRun . id ,
767
- name : checkRun . name ,
768
- conclusion : 'neutral' as 'neutral' ,
769
- completed_at : new Date ( ) . toISOString ( ) ,
770
- output : {
771
- title : 'Backport Failed' ,
772
- summary : `This PR was checked and could not be automatically backported to "${ targetBranch } " cleanly` ,
773
- text : diff
774
- ? `Failed Diff:\n\n${ mdSep } diff\n${ rawDiff } \n${ mdSep } `
775
- : undefined ,
776
- annotations : annotations ? annotations : undefined ,
777
- } ,
778
- } ) ;
779
- try {
780
- await context . octokit . checks . update ( updateOpts ) ;
781
- } catch ( err ) {
782
- // A GitHub error occurred - try to mark it as a failure without annotations.
783
- updateOpts . output ! . annotations = undefined ;
784
- await context . octokit . checks . update ( updateOpts ) ;
785
- }
758
+ const mdSep = '``````````````````````````````' ;
759
+ const updateOpts = context . repo ( {
760
+ check_run_id : checkRun . id ,
761
+ name : checkRun . name ,
762
+ conclusion : 'neutral' as 'neutral' ,
763
+ completed_at : new Date ( ) . toISOString ( ) ,
764
+ output : {
765
+ title : 'Backport Failed' ,
766
+ summary : `This PR was checked and could not be automatically backported to "${ targetBranch } " cleanly` ,
767
+ text : diff
768
+ ? `Failed Diff:\n\n${ mdSep } diff\n${ rawDiff } \n${ mdSep } `
769
+ : undefined ,
770
+ annotations : annotations ? annotations : undefined ,
771
+ } ,
772
+ } ) ;
773
+ try {
774
+ await context . octokit . checks . update ( updateOpts ) ;
775
+ } catch ( err ) {
776
+ // A GitHub error occurred - try to mark it as a failure without annotations.
777
+ updateOpts . output ! . annotations = undefined ;
778
+ await context . octokit . checks . update ( updateOpts ) ;
786
779
}
787
780
} ,
788
781
) ;
0 commit comments