dowloaded archive into tar

This commit is contained in:
Naveenraj M
2020-03-29 20:07:44 +05:30
parent 33e51511c7
commit 7e607fe325
4 changed files with 27 additions and 45 deletions

View File

@ -16,27 +16,21 @@ function download_archive(owner, repo, ref) {
try {
const octokit = new Octokit();
const archive_format = "tarball";
const ref = "v1.0.0";
const tag = "v1.0.0";
const tarFile = `${tag}.tar.gz`;
console.log("Calling API ...");
octokit.repos.getBranch({
octokit.repos.getArchiveLink({
owner,
repo,
archive_format,
ref
}).then(({ data }) => {
console.log(data);
fs.writeFileSync(tarFile, Buffer.from(data));
}).catch(function (error) {
console.log(error);
});
// octokit.repos.getArchiveLink({
// owner,
// repo,
// archive_format,
// ref
// }).then(( { data }) => {
// console.log(data)
// });
//console.log(`Download Location : ${downloadLocation}`);
//const tarBallPath = await tc.downloadTool(downloadLocation);
//console.log(`Tarball Location : ${tarBallPath}`);
//return tarBallPath;
console.log(`Tarball Location : ${tarFile}`);
return tarFile;
}
catch (error) {
core.setFailed(error.message);

View File

@ -28,16 +28,14 @@ function run() {
console.log(`Hello ${specFile} from inside a container`);
// Get repo files from /github/workspace/
yield exec.exec('ls -la /github/workspace');
// LOG: know current directory
yield exec.exec('pwd && echo $HOME && ls');
// Copy spec file from path specFile to /root/rpmbuild/SPECS/
//await io.cp('path/to/file', 'path/to/dest');
yield io.cp('/github/workspace/cello.spec', '/root/rpmbuild/SPECS/');
// Get tar.gz file of release
// 1. Write API call to download tar.gz from release OR
// 2. Create tar.gz of /github/workspace to get tar of source code
// Copy tar.gz file to /root/rpmbuild/SOURCES
// make sure the name of tar.gz is same as given in Source of spec file
//await io.cp('path/to/file', '/root/rpmbuild/SOURCES');
yield io.cp(tarBallPath, '/root/rpmbuild/SOURCES');
// Execute rpmbuild
try {
yield exec.exec(`rpmbuild -ba ${specFile}`);

View File

@ -9,35 +9,26 @@ async function download_archive(owner, repo, ref ) {
const octokit = new Octokit();
const archive_format = "tarball";
const ref = "v1.0.0"
const tag = "v1.0.0"
const tarFile = `${tag}.tar.gz`;
console.log("Calling API ...");
octokit.repos.getBranch({
octokit.repos.getArchiveLink({
owner,
repo,
archive_format,
ref
}).then(( { data }) => {
console.log(data);
});
}).then(( { data }) => {
fs.writeFileSync(tarFile, Buffer.from(data));
}).catch( function(error){
console.log(error);
});
console.log(`Tarball Location : ${tarFile}`);
// octokit.repos.getArchiveLink({
// owner,
// repo,
// archive_format,
// ref
// }).then(( { data }) => {
// console.log(data)
// });
//console.log(`Download Location : ${downloadLocation}`);
//const tarBallPath = await tc.downloadTool(downloadLocation);
//console.log(`Tarball Location : ${tarBallPath}`);
//return tarBallPath;
return tarFile;
} catch (error) {
core.setFailed(error.message);

View File

@ -26,11 +26,10 @@ async function run() {
// Get repo files from /github/workspace/
await exec.exec('ls -la /github/workspace');
// LOG: know current directory
await exec.exec('pwd && echo $HOME && ls');
// Copy spec file from path specFile to /root/rpmbuild/SPECS/
//await io.cp('path/to/file', 'path/to/dest');
await io.cp('/github/workspace/cello.spec', '/root/rpmbuild/SPECS/');
// Get tar.gz file of release
// 1. Write API call to download tar.gz from release OR
@ -38,7 +37,7 @@ async function run() {
// Copy tar.gz file to /root/rpmbuild/SOURCES
// make sure the name of tar.gz is same as given in Source of spec file
//await io.cp('path/to/file', '/root/rpmbuild/SOURCES');
await io.cp(tarBallPath, '/root/rpmbuild/SOURCES');
// Execute rpmbuild
try {