From 3d12753e2b6f5f62588a28f98d9ae1255d37f321 Mon Sep 17 00:00:00 2001 From: Naveenraj M Date: Sun, 29 Mar 2020 20:42:47 +0530 Subject: [PATCH] await till return --- lib/download-release-archive.js | 4 ++-- lib/main.js | 10 ++++------ src/download-release-archive.ts | 6 +++--- src/main.ts | 19 +++++++------------ 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/lib/download-release-archive.js b/lib/download-release-archive.js index e5dbbf7..bad95b0 100644 --- a/lib/download-release-archive.js +++ b/lib/download-release-archive.js @@ -30,12 +30,12 @@ function download_archive(owner, repo, ref) { return console.log(err); } console.log("The Tar file was saved!"); + console.log(`Tarball Location : ${tarFile}`); + return tarFile; }); }).catch(function (error) { console.log(error); }); - console.log(`Tarball Location : ${tarFile}`); - return tarFile; } catch (error) { core.setFailed(error.message); diff --git a/lib/main.js b/lib/main.js index ce2d5c1..9ef6535 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,19 +22,17 @@ function run() { const repo = context.repo.repo; const ref = context.ref; console.log(`We can even get context data, like the owner: ${owner}, repo: ${repo}, ref: ${ref}`); - const tarBallPath = yield download_tar(owner, repo, ref); - console.log(`Tar Path for copy : ${tarBallPath}`); const specFile = core.getInput('specFile'); console.log(`Hello ${specFile} from inside a container`); // Get repo files from /github/workspace/ - yield exec.exec('ls -la /github/workspace'); - // Get repo files from /github/workspace/ yield exec.exec('ls -la '); // Copy spec file from path specFile to /root/rpmbuild/SPECS/ 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 + const tarBallPath = yield download_tar(owner, repo, ref); + console.log(`Tar Path for copy : ${tarBallPath}`); + // Get repo files from /github/workspace/ + yield exec.exec('ls -la '); // Copy tar.gz file to /root/rpmbuild/SOURCES // make sure the name of tar.gz is same as given in Source of spec file yield io.cp(tarBallPath, '/root/rpmbuild/SOURCES'); diff --git a/src/download-release-archive.ts b/src/download-release-archive.ts index 46590a4..10f6f68 100644 --- a/src/download-release-archive.ts +++ b/src/download-release-archive.ts @@ -26,14 +26,14 @@ async function download_archive(owner, repo, ref ) { return console.log(err); } console.log("The Tar file was saved!"); + console.log(`Tarball Location : ${tarFile}`); + return tarFile; }); }).catch( function(error){ console.log(error); }); - console.log(`Tarball Location : ${tarFile}`); - - return tarFile; + } catch (error) { core.setFailed(error.message); diff --git a/src/main.ts b/src/main.ts index c26a891..05dc3a8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,25 +16,22 @@ async function run() { console.log(`We can even get context data, like the owner: ${owner}, repo: ${repo}, ref: ${ref}`); - const tarBallPath = await download_tar(owner, repo, ref); - - console.log(`Tar Path for copy : ${tarBallPath}`); - const specFile = core.getInput('specFile'); console.log(`Hello ${specFile} from inside a container`); - // Get repo files from /github/workspace/ - await exec.exec('ls -la /github/workspace'); - // Get repo files from /github/workspace/ await exec.exec('ls -la '); // Copy spec file from path specFile to /root/rpmbuild/SPECS/ 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 - // 2. Create tar.gz of /github/workspace to get tar of source code + const tarBallPath = await download_tar(owner, repo, ref); + + console.log(`Tar Path for copy : ${tarBallPath}`); + + // Get repo files from /github/workspace/ + await exec.exec('ls -la '); // Copy tar.gz file to /root/rpmbuild/SOURCES // make sure the name of tar.gz is same as given in Source of spec file @@ -58,8 +55,6 @@ async function run() { //core.setOutput("rpmPath", rpmPath) //core.setOutput("sourceRpmPath", sourceRpmPath) // make option to upload source rpm - - } catch (error) { core.setFailed(error.message); }