mirror of
https://github.com/naveenrajm7/rpmbuild.git
synced 2025-07-12 12:13:51 +00:00
tsc built
This commit is contained in:
35
lib/download-release-archive.js
Normal file
35
lib/download-release-archive.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
"use strict";
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const { Octokit } = require('@octokit/rest');
|
||||||
|
const fs = require('fs');
|
||||||
|
const tc = require('@actions/tool-cache');
|
||||||
|
function download_archive(owner, repo, ref) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
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 = yield tc.downloadTool(downloadLocation);
|
||||||
|
console.log(`Tarball Location : ${tarBallPath}`);
|
||||||
|
return tarBallPath;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
core.setFailed(error.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
module.exports = download_archive;
|
43
lib/main.js
43
lib/main.js
@ -1,22 +1,57 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
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 io = require('@actions/io');
|
||||||
|
const download_tar = require('./download-release-archive');
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const myInput = core.getInput('myInput');
|
|
||||||
core.debug(`Hello ${myInput} from inside a container`);
|
|
||||||
// Get github context data
|
// Get github context data
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
console.log(`We can even get context data, like the repo: ${context.repo.repo}`);
|
const owner = context.repo.owner;
|
||||||
|
const repo = context.repo.repo;
|
||||||
|
const ref = context.repo.ref;
|
||||||
|
console.log(`We can even get context data, like the owner: ${owner}, repo: ${repo}, ref: ${ref}`);
|
||||||
|
const tarBallPath = download_tar(owner, repo, ref);
|
||||||
|
console.log(`Tar Path for copy : ${tarBallPath}`);
|
||||||
|
const specFile = core.getInput('specFile');
|
||||||
|
core.debug(`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');
|
||||||
|
// 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');
|
||||||
|
// Execute rpmbuild
|
||||||
|
try {
|
||||||
|
yield exec.exec(`rpmbuild -ba ${specFile}`);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
core.setFailed(`action failed with error: ${err}`);
|
||||||
|
}
|
||||||
|
// 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
|
||||||
|
// 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
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
Reference in New Issue
Block a user