added file download-release-archive.ts

This commit is contained in:
Naveenraj M
2020-03-29 15:53:43 +05:30
parent c13daae69f
commit ab67f60c5e

View File

@ -0,0 +1,33 @@
const { Octokit } = require('@octokit/rest');
const fs = require('fs');
const tc = require('@actions/tool-cache');
async function download_archive(owner, repo, ref ) {
try {
const octokit = new Octokit();
const archive_format = "tarball";
const downloadLocation = octokit.repos.getArchiveLink({
owner,
repo,
archive_format,
ref
});
console.log(`Download Location : ${downloadLocation}`);
const tarBallPath = await tc.downloadTool(downloadLocation);
console.log(`Tarball Location : ${tarBallPath}`);
return tarBallPath;
} catch (error) {
core.setFailed(error.message);
}
}
module.exports = download_archive;