This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
import * as action_information from 'information';
|
||||
import {
|
||||
executeFpmBuild,
|
||||
isTrueString, prepareFpmArgs
|
||||
} from './lib';
|
||||
|
||||
|
||||
try {
|
||||
if (isTrueString(core.getBooleanInput('debug_log_github_context'))) {
|
||||
console.log(JSON.stringify(github.context, null, 2));
|
||||
}
|
||||
|
||||
const information = action_information.collect_all(true, false);
|
||||
const debug = isTrueString(process.env['ACTIONS_STEP_DEBUG']);
|
||||
|
||||
const fpmArgs = prepareFpmArgs();
|
||||
if (debug) {
|
||||
console.log('fpmArgs:', JSON.stringify(fpmArgs, null, 2));
|
||||
}
|
||||
|
||||
executeFpmBuild(fpmArgs);
|
||||
}
|
||||
catch (error) {
|
||||
console.log('Failed to fpm packages', error);
|
||||
core.setFailed(error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
import * as core from '@actions/core';
|
||||
import child_process from 'child_process';
|
||||
|
||||
export function prepareFpmArgs() {
|
||||
return '';
|
||||
}
|
||||
|
||||
export function executeFpmBuild(computedFpmArgs) {
|
||||
|
||||
const userFpmArgs = core.getInput('fpm_args');
|
||||
const dockerCmd = 'docker run --rm -i'
|
||||
+ ' -v ' + process.cwd() + ':/workspace/source'
|
||||
+ ' -w /workspace/source'
|
||||
+ 'gitea.dhswt.de/actions/fpm:latest'
|
||||
+ ' ' + computedFpmArgs
|
||||
+ ' ' + userFpmArgs;
|
||||
|
||||
const proc = child_process.spawnSync(dockerCmd, {
|
||||
shell: true,
|
||||
stdio: 'inherit',
|
||||
cwd : process.cwd()
|
||||
});
|
||||
|
||||
if (proc.status != null && proc.status > 0) {
|
||||
throw new Error('fpm build failed');
|
||||
}
|
||||
|
||||
if (proc.error != null) {
|
||||
throw proc.error;
|
||||
}
|
||||
}
|
||||
|
||||
function isNonEmptyStr(str) {
|
||||
return str != null && str !== 'false' && str.length > 0;
|
||||
}
|
||||
|
||||
export function isTrueString(str) {
|
||||
return str === '1'
|
||||
|| str === 'true'
|
||||
|| str === 'True'
|
||||
|| str === 'TRUE';
|
||||
}
|
||||
Reference in New Issue
Block a user