1
0
Fork 0
mirror of https://github.com/docker/build-push-action.git synced 2025-04-02 13:10:08 +02:00

add squash option

Signed-off-by: xundaoxd <xundaoxd@outlook.com>
This commit is contained in:
xundaoxd 2022-10-06 20:08:54 +08:00
parent 83a00fb5e6
commit 77bf341f1f
6 changed files with 30 additions and 3 deletions

View file

@ -238,6 +238,7 @@ Following inputs can be used as `step.with` keys
| `target` | String | Sets the target stage to build |
| `ulimit` | List | [Ulimit](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-set-ulimits---ulimit) options (e.g., `nofile=1024:1024`) |
| `github-token` | String | GitHub Token used to authenticate against a repository for [Git context](#git-context) (default `${{ github.token }}`) |
| `squash` | Bool | Squash newly built layers into a single new layer |
### outputs

View file

@ -149,6 +149,7 @@ describe('getArgs', () => {
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -165,6 +166,7 @@ describe('getArgs', () => {
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -183,6 +185,7 @@ describe('getArgs', () => {
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -203,6 +206,7 @@ describe('getArgs', () => {
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -222,6 +226,7 @@ describe('getArgs', () => {
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -238,6 +243,7 @@ describe('getArgs', () => {
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -255,6 +261,7 @@ describe('getArgs', () => {
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -273,6 +280,7 @@ describe('getArgs', () => {
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -295,6 +303,7 @@ describe('getArgs', () => {
['no-cache', 'false'],
['push', 'true'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -329,6 +338,7 @@ ccc"`],
['no-cache', 'false'],
['push', 'true'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -366,6 +376,7 @@ ccc`],
['no-cache', 'false'],
['push', 'true'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -395,6 +406,7 @@ ccc`],
['no-cache', 'false'],
['push', 'true'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -418,6 +430,7 @@ ccc`],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -440,6 +453,7 @@ ccc`],
['no-cache', 'false'],
['push', 'true'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -468,6 +482,7 @@ nproc=3`],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -492,6 +507,7 @@ nproc=3`],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',
@ -510,6 +526,7 @@ nproc=3`],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
['squash', 'false'],
]),
[
'build',

View file

@ -93,6 +93,10 @@ inputs:
description: "GitHub Token used to authenticate against a repository for Git context"
default: ${{ github.token }}
required: false
squash:
description: "Squash newly built layers into a single new layer"
required: false
default: 'false'
outputs:
imageid:

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -41,6 +41,7 @@ export interface Inputs {
target: string;
ulimit: string[];
githubToken: string;
squash: boolean;
}
export function defaultContext(): string {
@ -96,7 +97,8 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
tags: await getInputList('tags'),
target: core.getInput('target'),
ulimit: await getInputList('ulimit', true),
githubToken: core.getInput('github-token')
githubToken: core.getInput('github-token'),
squash: core.getBooleanInput('squash')
};
}
@ -185,6 +187,9 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, context: str
await asyncForEach(inputs.ulimit, async ulimit => {
args.push('--ulimit', ulimit);
});
if (inputs.squash) {
args.push('--squash');
}
return args;
}