prototype fpm build with docker action
Docker Build / docker-build (push) Successful in 1m9s

This commit is contained in:
2023-12-24 14:46:48 +01:00
parent 83e68509ce
commit 126c9089bf
6 changed files with 79609 additions and 0 deletions
+29
View File
@@ -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
View File
@@ -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';
}