mirror of
https://github.com/naveenrajm7/rpmbuild.git
synced 2025-07-12 12:13:51 +00:00
setting steps
This commit is contained in:
34
src/main.ts
34
src/main.ts
@ -1,11 +1,17 @@
|
|||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
const github = require('@actions/github');
|
const github = require('@actions/github');
|
||||||
const exec = require('@actions/exec');
|
const exec = require('@actions/exec');
|
||||||
|
const io = require('@actions/io');
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const myInput = core.getInput('specFile');
|
|
||||||
core.debug(`Hello ${myInput} from inside a container`);
|
// Get github context data
|
||||||
|
const context = github.context;
|
||||||
|
console.log(`We can even get context data, like the repo: ${context.repo.repo}`);
|
||||||
|
|
||||||
|
const specFile = core.getInput('specFile');
|
||||||
|
core.debug(`Hello ${specFile} from inside a container`);
|
||||||
|
|
||||||
// Get repo files from /github/workspace/
|
// Get repo files from /github/workspace/
|
||||||
await exec.exec('ls -la /github/workspace');
|
await exec.exec('ls -la /github/workspace');
|
||||||
@ -14,27 +20,35 @@ async function run() {
|
|||||||
await exec.exec('pwd && echo $HOME && ls');
|
await exec.exec('pwd && echo $HOME && ls');
|
||||||
|
|
||||||
// Copy spec file from path specFile to /root/rpmbuild/SPECS/
|
// Copy spec file from path specFile to /root/rpmbuild/SPECS/
|
||||||
|
await io.cp('path/to/file', 'path/to/dest');
|
||||||
|
|
||||||
// Get tar.gz file of release
|
// 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
|
// 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');
|
||||||
|
|
||||||
// Execute rpmbuild
|
// Execute rpmbuild
|
||||||
|
try {
|
||||||
|
await exec.exec(
|
||||||
|
`rpmbuild -ba ${specFile}`
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
core.setFailed(`action failed with error: ${err}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Get path for rpm
|
// Get path for rpm
|
||||||
|
//const rpmPath = await exec.exec('node', ['index.js', 'foo=bar'], options);
|
||||||
|
|
||||||
// setOutput rpm_path to /root/rpmbuild/RPMS , to be consumed by other actions like
|
// setOutput rpm_path to /root/rpmbuild/RPMS , to be consumed by other actions like
|
||||||
// actions/upload-release-asset
|
// actions/upload-release-asset
|
||||||
|
// If you want to upload yourself , need to write api call to upload as asset
|
||||||
|
core.setOutput("rpmPath", rpmPath)
|
||||||
|
core.setOutput("sourceRpmPath", sourceRpmPath) // make option to upload source rpm
|
||||||
|
|
||||||
|
|
||||||
// Get github context data
|
|
||||||
const context = github.context;
|
|
||||||
console.log(`We can even get context data, like the repo: ${context.repo.repo}`);
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
Reference in New Issue
Block a user