2019-12-10 05:54:42 +08:00
|
|
|
import * as github from '@actions/github'
|
|
|
|
import {ReposGetArchiveLinkParams} from '@octokit/rest'
|
|
|
|
|
|
|
|
const IS_WINDOWS = process.platform === 'win32'
|
|
|
|
|
2019-12-10 06:01:19 +08:00
|
|
|
export async function downloadRepository(
|
2019-12-10 05:54:42 +08:00
|
|
|
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)}`)
|
2019-12-10 06:01:19 +08:00
|
|
|
console.log(`data=${JSON.stringify(typeof response.data)}`)
|
2019-12-10 05:54:42 +08:00
|
|
|
}
|