mirror of
				https://github.com/actions/checkout.git
				synced 2025-11-04 07:48:09 +08:00 
			
		
		
		
	fallback to REST API to download repo
This commit is contained in:
		
							
								
								
									
										24
									
								
								src/repository-api-helper.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/repository-api-helper.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
import * as github from '@actions/github'
 | 
			
		||||
import {ReposGetArchiveLinkParams} from '@octokit/rest'
 | 
			
		||||
 | 
			
		||||
const IS_WINDOWS = process.platform === 'win32'
 | 
			
		||||
 | 
			
		||||
export async function download(
 | 
			
		||||
  accessToken: string,
 | 
			
		||||
  owner: string,
 | 
			
		||||
  repo: string,
 | 
			
		||||
  ref: string,
 | 
			
		||||
  repositoryPath: string
 | 
			
		||||
): Promise<void> {
 | 
			
		||||
  const octokit = new github.GitHub(accessToken)
 | 
			
		||||
  const params: ReposGetArchiveLinkParams = {
 | 
			
		||||
    archive_format: IS_WINDOWS ? 'zipball' : 'tarball',
 | 
			
		||||
    owner: owner,
 | 
			
		||||
    repo: repo,
 | 
			
		||||
    ref: ref
 | 
			
		||||
  }
 | 
			
		||||
  const response = await octokit.repos.getArchiveLink(params)
 | 
			
		||||
  console.log(`status=${response.status}`)
 | 
			
		||||
  console.log(`headers=${JSON.stringify(response.headers)}`)
 | 
			
		||||
  console.log(`data=${JSON.stringify(response.data)}`)
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user