assembled docker args
This commit is contained in:
parent
8b24f0e395
commit
e35b2f2658
43
dist/index.js
vendored
43
dist/index.js
vendored
@ -61795,6 +61795,8 @@ function collect_all(debug = false, output = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
;// CONCATENATED MODULE: external "child_process"
|
||||||
|
const external_child_process_namespaceObject = require("child_process");
|
||||||
// EXTERNAL MODULE: external "fs"
|
// EXTERNAL MODULE: external "fs"
|
||||||
var external_fs_ = __nccwpck_require__(7147);
|
var external_fs_ = __nccwpck_require__(7147);
|
||||||
;// CONCATENATED MODULE: ./node_modules/js-base64/base64.mjs
|
;// CONCATENATED MODULE: ./node_modules/js-base64/base64.mjs
|
||||||
@ -62104,6 +62106,7 @@ var external_path_ = __nccwpck_require__(1017);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function processAdditionalRegistries(targetRegistries) {
|
function processAdditionalRegistries(targetRegistries) {
|
||||||
const additionalRegistries = core.getInput('additional_registries');
|
const additionalRegistries = core.getInput('additional_registries');
|
||||||
if (additionalRegistries != null && additionalRegistries.length > 0) {
|
if (additionalRegistries != null && additionalRegistries.length > 0) {
|
||||||
@ -62224,6 +62227,15 @@ function prepareDestinations(registries, tags) {
|
|||||||
return destinations;
|
return destinations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDockerContextDir() {
|
||||||
|
if (isNonEmptyStr(core.getInput('docker_context_dir'))) {
|
||||||
|
return core.getInput('docker_context_dir');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return process.env['GITHUB_WORKSPACE'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function prepareDockerArgs(destinations) {
|
function prepareDockerArgs(destinations) {
|
||||||
let dockerArgs = (core.getInput('docker_args') ?? '').trim();
|
let dockerArgs = (core.getInput('docker_args') ?? '').trim();
|
||||||
if (dockerArgs.length > 0) {
|
if (dockerArgs.length > 0) {
|
||||||
@ -62237,12 +62249,7 @@ function prepareDockerArgs(destinations) {
|
|||||||
dockerArgs.unshift('--file ' + core.getInput('dockerfile'));
|
dockerArgs.unshift('--file ' + core.getInput('dockerfile'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNonEmptyStr(core.getInput('docker_context_dir'))) {
|
dockerArgs.unshift(getDockerContextDir());
|
||||||
dockerArgs.unshift(core.getInput('docker_context_dir'));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
dockerArgs.unshift(process.env['GITHUB_WORKSPACE']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (core.getBooleanInput('squash_layers')) {
|
if (core.getBooleanInput('squash_layers')) {
|
||||||
dockerArgs.push('--squash');
|
dockerArgs.push('--squash');
|
||||||
@ -62259,6 +62266,28 @@ function prepareDockerArgs(destinations) {
|
|||||||
return dockerArgs;
|
return dockerArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function lib_executeDockerBuild(dockerArgs) {
|
||||||
|
const dockerArgsStr = dockerArgs.join(' ');
|
||||||
|
|
||||||
|
const proc = child_process.spawnSync('docker ' + dockerArgsStr, {
|
||||||
|
shell: true,
|
||||||
|
stdio: 'inherit',
|
||||||
|
cwd : getDockerContextDir()
|
||||||
|
});
|
||||||
|
|
||||||
|
// proc.on('exit', function (code, signal) {
|
||||||
|
// console.log(`docker process exited with code ${code} and signal ${signal}`);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// proc.stdout.on('data', (data) => {
|
||||||
|
// console.log(`docker: ${data}`);
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// proc.stderr.on('data', (data) => {
|
||||||
|
// console.error(`docker: ${data}`);
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ./src/action.js
|
;// CONCATENATED MODULE: ./src/action.js
|
||||||
|
|
||||||
|
|
||||||
@ -62301,6 +62330,8 @@ try {
|
|||||||
if (debug) {
|
if (debug) {
|
||||||
console.log('dockerArgs:', JSON.stringify(dockerArgs, null, 2));
|
console.log('dockerArgs:', JSON.stringify(dockerArgs, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
executeDockerBuild(dockerArgs);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.log('Failed to build docker image', error);
|
console.log('Failed to build docker image', error);
|
||||||
|
|||||||
@ -46,6 +46,8 @@ try {
|
|||||||
if (debug) {
|
if (debug) {
|
||||||
console.log('dockerArgs:', JSON.stringify(dockerArgs, null, 2));
|
console.log('dockerArgs:', JSON.stringify(dockerArgs, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
executeDockerBuild(dockerArgs);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.log('Failed to build docker image', error);
|
console.log('Failed to build docker image', error);
|
||||||
|
|||||||
39
src/lib.js
39
src/lib.js
@ -1,5 +1,6 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as github from '@actions/github';
|
import * as github from '@actions/github';
|
||||||
|
import * as child_process from 'child_process';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import {Base64} from 'js-base64';
|
import {Base64} from 'js-base64';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
@ -124,6 +125,15 @@ export function prepareDestinations(registries, tags) {
|
|||||||
return destinations;
|
return destinations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getDockerContextDir() {
|
||||||
|
if (isNonEmptyStr(core.getInput('docker_context_dir'))) {
|
||||||
|
return core.getInput('docker_context_dir');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return process.env['GITHUB_WORKSPACE'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function prepareDockerArgs(destinations) {
|
export function prepareDockerArgs(destinations) {
|
||||||
let dockerArgs = (core.getInput('docker_args') ?? '').trim();
|
let dockerArgs = (core.getInput('docker_args') ?? '').trim();
|
||||||
if (dockerArgs.length > 0) {
|
if (dockerArgs.length > 0) {
|
||||||
@ -137,12 +147,7 @@ export function prepareDockerArgs(destinations) {
|
|||||||
dockerArgs.unshift('--file ' + core.getInput('dockerfile'));
|
dockerArgs.unshift('--file ' + core.getInput('dockerfile'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNonEmptyStr(core.getInput('docker_context_dir'))) {
|
dockerArgs.unshift(getDockerContextDir());
|
||||||
dockerArgs.unshift(core.getInput('docker_context_dir'));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
dockerArgs.unshift(process.env['GITHUB_WORKSPACE']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (core.getBooleanInput('squash_layers')) {
|
if (core.getBooleanInput('squash_layers')) {
|
||||||
dockerArgs.push('--squash');
|
dockerArgs.push('--squash');
|
||||||
@ -158,3 +163,25 @@ export function prepareDockerArgs(destinations) {
|
|||||||
|
|
||||||
return dockerArgs;
|
return dockerArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function executeDockerBuild(dockerArgs) {
|
||||||
|
const dockerArgsStr = dockerArgs.join(' ');
|
||||||
|
|
||||||
|
const proc = child_process.spawnSync('docker ' + dockerArgsStr, {
|
||||||
|
shell: true,
|
||||||
|
stdio: 'inherit',
|
||||||
|
cwd : getDockerContextDir()
|
||||||
|
});
|
||||||
|
|
||||||
|
// proc.on('exit', function (code, signal) {
|
||||||
|
// console.log(`docker process exited with code ${code} and signal ${signal}`);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// proc.stdout.on('data', (data) => {
|
||||||
|
// console.log(`docker: ${data}`);
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// proc.stderr.on('data', (data) => {
|
||||||
|
// console.error(`docker: ${data}`);
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user