mirror of
https://github.com/docker/build-push-action.git
synced 2025-04-02 21:20:06 +02:00
Add context-subdir input
Adds a `context-subdir` input which gets appended to the context URL. This new input is ignored (with a warning) if the user gives a non-default `context` input such as a path. Signed-off-by: actualben <actualben@users.noreply.github.com>
This commit is contained in:
parent
b1aeb1103e
commit
e946f387af
4 changed files with 62 additions and 2 deletions
|
@ -491,6 +491,43 @@ nproc=3`],
|
||||||
'.'
|
'.'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
15,
|
||||||
|
'0.7.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context-subdir', 'test'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'buildx',
|
||||||
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'https://github.com/docker/build-push-action.git#refs/heads/test-jest:test'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
16,
|
||||||
|
'0.7.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context', './test'],
|
||||||
|
['context-subdir', 'should-be-ignored'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'buildx',
|
||||||
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'./test'
|
||||||
|
]
|
||||||
|
],
|
||||||
])(
|
])(
|
||||||
'[%d] given %p with %p as inputs, returns %p',
|
'[%d] given %p with %p as inputs, returns %p',
|
||||||
async (num: number, buildxVersion: string, inputs: Map<string, any>, expected: Array<string>) => {
|
async (num: number, buildxVersion: string, inputs: Map<string, any>, expected: Array<string>) => {
|
||||||
|
|
|
@ -28,6 +28,9 @@ inputs:
|
||||||
context:
|
context:
|
||||||
description: "Build's context is the set of files located in the specified PATH or URL"
|
description: "Build's context is the set of files located in the specified PATH or URL"
|
||||||
required: false
|
required: false
|
||||||
|
context-subdir:
|
||||||
|
description: "Subdirectory of the git repo to use as the docker build context (when using a URL-based context)"
|
||||||
|
required: false
|
||||||
file:
|
file:
|
||||||
description: "Path to the Dockerfile"
|
description: "Path to the Dockerfile"
|
||||||
required: false
|
required: false
|
||||||
|
|
12
dist/index.js
generated
vendored
12
dist/index.js
generated
vendored
|
@ -276,6 +276,7 @@ function getInputs(defaultContext) {
|
||||||
cacheTo: yield getInputList('cache-to', true),
|
cacheTo: yield getInputList('cache-to', true),
|
||||||
cgroupParent: core.getInput('cgroup-parent'),
|
cgroupParent: core.getInput('cgroup-parent'),
|
||||||
context: core.getInput('context') || defaultContext,
|
context: core.getInput('context') || defaultContext,
|
||||||
|
contextSubdir: core.getInput('context-subdir'),
|
||||||
file: core.getInput('file'),
|
file: core.getInput('file'),
|
||||||
labels: yield getInputList('labels', true),
|
labels: yield getInputList('labels', true),
|
||||||
load: core.getBooleanInput('load'),
|
load: core.getBooleanInput('load'),
|
||||||
|
@ -302,7 +303,16 @@ function getArgs(inputs, defaultContext, buildxVersion) {
|
||||||
let args = ['buildx'];
|
let args = ['buildx'];
|
||||||
args.push.apply(args, yield getBuildArgs(inputs, defaultContext, buildxVersion));
|
args.push.apply(args, yield getBuildArgs(inputs, defaultContext, buildxVersion));
|
||||||
args.push.apply(args, yield getCommonArgs(inputs, buildxVersion));
|
args.push.apply(args, yield getCommonArgs(inputs, buildxVersion));
|
||||||
args.push(inputs.context);
|
let context = inputs.context;
|
||||||
|
if (inputs.contextSubdir) {
|
||||||
|
if (context == defaultContext) {
|
||||||
|
context = `${context}:${inputs.contextSubdir}`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.warning('"context-subdir" input is ignored when a "context" input is present');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
args.push(context);
|
||||||
return args;
|
return args;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ export interface Inputs {
|
||||||
cacheTo: string[];
|
cacheTo: string[];
|
||||||
cgroupParent: string;
|
cgroupParent: string;
|
||||||
context: string;
|
context: string;
|
||||||
|
contextSubdir: string;
|
||||||
file: string;
|
file: string;
|
||||||
labels: string[];
|
labels: string[];
|
||||||
load: boolean;
|
load: boolean;
|
||||||
|
@ -73,6 +74,7 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
|
||||||
cacheTo: await getInputList('cache-to', true),
|
cacheTo: await getInputList('cache-to', true),
|
||||||
cgroupParent: core.getInput('cgroup-parent'),
|
cgroupParent: core.getInput('cgroup-parent'),
|
||||||
context: core.getInput('context') || defaultContext,
|
context: core.getInput('context') || defaultContext,
|
||||||
|
contextSubdir: core.getInput('context-subdir'),
|
||||||
file: core.getInput('file'),
|
file: core.getInput('file'),
|
||||||
labels: await getInputList('labels', true),
|
labels: await getInputList('labels', true),
|
||||||
load: core.getBooleanInput('load'),
|
load: core.getBooleanInput('load'),
|
||||||
|
@ -97,7 +99,15 @@ export async function getArgs(inputs: Inputs, defaultContext: string, buildxVers
|
||||||
let args: Array<string> = ['buildx'];
|
let args: Array<string> = ['buildx'];
|
||||||
args.push.apply(args, await getBuildArgs(inputs, defaultContext, buildxVersion));
|
args.push.apply(args, await getBuildArgs(inputs, defaultContext, buildxVersion));
|
||||||
args.push.apply(args, await getCommonArgs(inputs, buildxVersion));
|
args.push.apply(args, await getCommonArgs(inputs, buildxVersion));
|
||||||
args.push(inputs.context);
|
let context: string = inputs.context;
|
||||||
|
if (inputs.contextSubdir) {
|
||||||
|
if (context == defaultContext) {
|
||||||
|
context = `${context}:${inputs.contextSubdir}`;
|
||||||
|
} else {
|
||||||
|
core.warning('"context-subdir" input is ignored when a "context" input is present');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
args.push(context);
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue