code clean

This commit is contained in:
Naveenraj M
2020-03-30 16:01:37 +05:30
parent dd228e741d
commit 08c27c427d
2 changed files with 18 additions and 24 deletions

View File

@ -23,23 +23,24 @@ function run() {
const repo = context.repo.repo;
const ref = context.ref;
const version = "1.0.0";
console.log(`We can even get context data, like the owner: ${owner}, repo: ${repo}, ref: ${ref}`);
const specFile = core.getInput('specFile');
console.log(`Hello ${specFile} from inside a container`);
// get inputs from workflow
const specFile = core.getInput('spec_file');
// setup rpm tree
yield exec.exec('rpmdev-setuptree');
// Copy spec file from path specFile to /root/rpmbuild/SPECS/
yield io.cp(`/github/workspace/${specFile}`, '/github/home/rpmbuild/SPECS/');
yield exec.exec(`cp /github/workspace/${specFile} /github/home/rpmbuild/SPECS/`);
// Dowload tar.gz file of source code
yield exec.exec(`curl -L --output tmp.tar.gz https://api.github.com/repos/${owner}/${repo}/tarball/${ref}`);
// create directory to match source file - repo-version
yield exec.exec(`mkdir ${repo}-${version}`);
// Extract source code to directory
yield exec.exec(`tar xvf tmp.tar.gz -C ${repo}-${version} --strip-components 1`);
// Create Source tar.gz file
yield exec.exec(`tar -czvf ${repo}-${version}.tar.gz ${repo}-${version}`);
// Get repo files from /github/workspace/
yield exec.exec('ls -la ');
// Copy tar.gz file to source
yield exec.exec(`cp ${repo}-${version}.tar.gz /github/home/rpmbuild/SOURCES/`);
// 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(tarBallPath, '/root/rpmbuild/SOURCES');
// Execute rpmbuild
try {
yield exec.exec(`rpmbuild -ba /github/home/rpmbuild/SPECS/${specFile}`);
@ -47,13 +48,10 @@ function run() {
catch (err) {
core.setFailed(`action failed with error: ${err}`);
}
// Get path for rpm
//const rpmPath = await exec.exec('node', ['index.js', 'foo=bar'], options);
// Verify RPM created
yield exec.exec('ls /github/home/rpmbuild/RPMS');
// setOutput rpm_path to /root/rpmbuild/RPMS , to be consumed by other actions like
// actions/upload-release-asset
// If you want to upload yourself , need to write api call to upload as asset
//core.setOutput("rpmPath", rpmPath)
let myOutput = '';
yield cp.exec('ls /github/home/rpmbuild/SRPMS/', (err, stdout, stderr) => {
if (err) {

View File

@ -17,33 +17,32 @@ async function run() {
const version = "1.0.0"
console.log(`We can even get context data, like the owner: ${owner}, repo: ${repo}, ref: ${ref}`);
const specFile = core.getInput('specFile');
console.log(`Hello ${specFile} from inside a container`);
// get inputs from workflow
const specFile = core.getInput('spec_file');
// setup rpm tree
await exec.exec('rpmdev-setuptree');
// Copy spec file from path specFile to /root/rpmbuild/SPECS/
await io.cp(`/github/workspace/${specFile}`, '/github/home/rpmbuild/SPECS/');
await exec.exec(`cp /github/workspace/${specFile} /github/home/rpmbuild/SPECS/`);
// Dowload tar.gz file of source code
await exec.exec(`curl -L --output tmp.tar.gz https://api.github.com/repos/${owner}/${repo}/tarball/${ref}`)
// create directory to match source file - repo-version
await exec.exec(`mkdir ${repo}-${version}`);
// Extract source code to directory
await exec.exec(`tar xvf tmp.tar.gz -C ${repo}-${version} --strip-components 1`);
// Create Source tar.gz file
await exec.exec(`tar -czvf ${repo}-${version}.tar.gz ${repo}-${version}`);
// Get repo files from /github/workspace/
await exec.exec('ls -la ');
// Copy tar.gz file to source
await exec.exec(`cp ${repo}-${version}.tar.gz /github/home/rpmbuild/SOURCES/`);
// 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(tarBallPath, '/root/rpmbuild/SOURCES');
// Execute rpmbuild
try {
await exec.exec(
@ -53,14 +52,11 @@ async function run() {
core.setFailed(`action failed with error: ${err}`);
}
// Get path for rpm
//const rpmPath = await exec.exec('node', ['index.js', 'foo=bar'], options);
// Verify RPM created
await exec.exec('ls /github/home/rpmbuild/RPMS');
// setOutput rpm_path to /root/rpmbuild/RPMS , to be consumed by other actions like
// actions/upload-release-asset
// If you want to upload yourself , need to write api call to upload as asset
//core.setOutput("rpmPath", rpmPath)
let myOutput = '';
await cp.exec('ls /github/home/rpmbuild/SRPMS/', (err, stdout, stderr) => {