File tree Expand file tree Collapse file tree 4 files changed +35
-2
lines changed Expand file tree Collapse file tree 4 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ inputs:
1919    description : GitHub token for destination repository 
2020    required : true 
2121    default : ${{ github.token }} 
22+   success-if-not-found :
23+     description : If true, the action will not fail if the namespace is not found 
24+     required : false 
25+     default : ' true' 
2226
2327outputs :
2428  application-versions :
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ const main = async (): Promise<void> => {
88    sourceRepository : core . getInput ( 'source-repository' ,  {  required : true  } ) , 
99    destinationRepository : core . getInput ( 'destination-repository' ,  {  required : true  } ) , 
1010    destinationRepositoryToken : core . getInput ( 'destination-repository-token' ,  {  required : true  } ) , 
11+     successIfNotFound : core . getBooleanInput ( 'success-if-not-found' )  ||  true , 
1112  } ) 
1213} 
1314
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ type Inputs = {
88  sourceRepository : string 
99  destinationRepository : string 
1010  destinationRepositoryToken : string 
11+   successIfNotFound : boolean 
1112} 
1213
1314type  Outputs  =  ApplicationVersion [ ] 
@@ -20,9 +21,20 @@ export const run = async (inputs: Inputs): Promise<void> => {
2021  } 
2122} 
2223
23- const  getServiceVersions  =  async  ( inputs : Inputs ) : Promise < Outputs >  =>  { 
24+ export   const  getServiceVersions  =  async  ( inputs : Inputs ) : Promise < Outputs >  =>  { 
2425  core . info ( `Checking out the namespace branch` ) 
25-   const  namespaceDirectory  =  await  checkoutNamespaceBranch ( inputs ) 
26+   let  namespaceDirectory : string 
27+ 
28+   try  { 
29+     namespaceDirectory  =  await  checkoutNamespaceBranch ( inputs ) 
30+   }  catch  ( error )  { 
31+     if  ( inputs . successIfNotFound )  { 
32+       core . warning ( `Namespace branch not found, returning empty list` ) 
33+       return  [ ] 
34+     } 
35+ 
36+     throw  error 
37+   } 
2638  core . debug ( `Namespace directory: ${ namespaceDirectory }  ` ) 
2739
2840  const  applicationFiles  =  await  listApplicationFiles ( namespaceDirectory ) 
Original file line number Diff line number Diff line change 11import  *  as  os  from  'os' 
22import  *  as  path  from  'path' 
33import  {  promises  as  fs  }  from  'fs' 
4+ import  {  getServiceVersions  }  from  '../src/run.js' 
45import  {  listApplicationFiles ,  readApplication  }  from  '../src/application.js' 
56
67const  createEmptyDirectory  =  async  ( )  =>  await  fs . mkdtemp ( path . join ( os . tmpdir ( ) ,  'bootstrap-pull-request-' ) ) 
78
9+ describe ( 'getServiceVersions' ,  ( )  =>  { 
10+   it ( 'returnes empty list if successIfNotFound' ,  async  ( )  =>  { 
11+     const  result  =  await  getServiceVersions ( { 
12+       overlay : 'overlay' , 
13+       namespace : 'namespace' , 
14+       sourceRepository : 'sourceRepository' , 
15+       destinationRepository : 'destinationRepository' , 
16+       destinationRepositoryToken : 'destinationRepositoryToken' , 
17+       successIfNotFound : true , 
18+     } ) 
19+ 
20+     expect ( result ) . toStrictEqual ( [ ] ) 
21+   } ) 
22+ } ) 
23+ 
824describe ( 'listApplicationFiles' ,  ( )  =>  { 
925  it ( 'lists up the application files, not other files' ,  async  ( )  =>  { 
1026    const  namespaceDirectory  =  await  createEmptyDirectory ( ) 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments