mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-30 04:00:57 -05:00
Merge pull request #1265 from crazy-max/call-check
call input to set method for evaluating build
This commit is contained in:
commit
0259cb088b
7 changed files with 54 additions and 6 deletions
32
.github/workflows/ci.yml
vendored
32
.github/workflows/ci.yml
vendored
|
@ -288,7 +288,6 @@ jobs:
|
||||||
-
|
-
|
||||||
name: Check
|
name: Check
|
||||||
run: |
|
run: |
|
||||||
echo "${{ toJson(steps.docker_build) }}"
|
|
||||||
if [ "${{ steps.docker_build.outcome }}" != "failure" ] || [ "${{ steps.docker_build.conclusion }}" != "success" ]; then
|
if [ "${{ steps.docker_build.outcome }}" != "failure" ] || [ "${{ steps.docker_build.conclusion }}" != "success" ]; then
|
||||||
echo "::error::Should have failed"
|
echo "::error::Should have failed"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -324,7 +323,6 @@ jobs:
|
||||||
-
|
-
|
||||||
name: Check
|
name: Check
|
||||||
run: |
|
run: |
|
||||||
echo "${{ toJson(steps.docker_build) }}"
|
|
||||||
if [ "${{ steps.docker_build.outcome }}" != "failure" ] || [ "${{ steps.docker_build.conclusion }}" != "success" ]; then
|
if [ "${{ steps.docker_build.outcome }}" != "failure" ] || [ "${{ steps.docker_build.conclusion }}" != "success" ]; then
|
||||||
echo "::error::Should have failed"
|
echo "::error::Should have failed"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -1511,3 +1509,33 @@ jobs:
|
||||||
file: ./test/lint.Dockerfile
|
file: ./test/lint.Dockerfile
|
||||||
env:
|
env:
|
||||||
DOCKER_BUILD_CHECKS_ANNOTATIONS: false
|
DOCKER_BUILD_CHECKS_ANNOTATIONS: false
|
||||||
|
|
||||||
|
call-check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
id: docker_build
|
||||||
|
continue-on-error: true
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
context: ./test
|
||||||
|
file: ./test/lint.Dockerfile
|
||||||
|
call: check
|
||||||
|
-
|
||||||
|
name: Check
|
||||||
|
run: |
|
||||||
|
if [ "${{ steps.docker_build.outcome }}" != "failure" ] || [ "${{ steps.docker_build.conclusion }}" != "success" ]; then
|
||||||
|
echo "::error::Should have failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
|
@ -220,6 +220,7 @@ The following inputs can be used as `step.with` keys:
|
||||||
| `build-contexts` | List | List of additional [build contexts](https://docs.docker.com/engine/reference/commandline/buildx_build/#build-context) (e.g., `name=path`) |
|
| `build-contexts` | List | List of additional [build contexts](https://docs.docker.com/engine/reference/commandline/buildx_build/#build-context) (e.g., `name=path`) |
|
||||||
| `cache-from` | List | List of [external cache sources](https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-from) (e.g., `type=local,src=path/to/dir`) |
|
| `cache-from` | List | List of [external cache sources](https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-from) (e.g., `type=local,src=path/to/dir`) |
|
||||||
| `cache-to` | List | List of [cache export destinations](https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-to) (e.g., `type=local,dest=path/to/dir`) |
|
| `cache-to` | List | List of [cache export destinations](https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-to) (e.g., `type=local,dest=path/to/dir`) |
|
||||||
|
| `call` | String | Set [method for evaluating build](https://docs.docker.com/reference/cli/docker/buildx/build/#call) (e.g., `check`) |
|
||||||
| `cgroup-parent` | String | Optional [parent cgroup](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) for the container used in the build |
|
| `cgroup-parent` | String | Optional [parent cgroup](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) for the container used in the build |
|
||||||
| `context` | String | Build's context is the set of files located in the specified [`PATH` or `URL`](https://docs.docker.com/engine/reference/commandline/build/) (default [Git context](#git-context)) |
|
| `context` | String | Build's context is the set of files located in the specified [`PATH` or `URL`](https://docs.docker.com/engine/reference/commandline/build/) (default [Git context](#git-context)) |
|
||||||
| `file` | String | Path to the Dockerfile. (default `{context}/Dockerfile`) |
|
| `file` | String | Path to the Dockerfile. (default `{context}/Dockerfile`) |
|
||||||
|
|
|
@ -34,6 +34,9 @@ inputs:
|
||||||
cache-to:
|
cache-to:
|
||||||
description: "List of cache export destinations for buildx (e.g., user/app:cache, type=local,dest=path/to/dir)"
|
description: "List of cache export destinations for buildx (e.g., user/app:cache, type=local,dest=path/to/dir)"
|
||||||
required: false
|
required: false
|
||||||
|
call:
|
||||||
|
description: "Set method for evaluating build (e.g., check)"
|
||||||
|
required: false
|
||||||
cgroup-parent:
|
cgroup-parent:
|
||||||
description: "Optional parent cgroup for the container used in the build"
|
description: "Optional parent cgroup for the container used in the build"
|
||||||
required: false
|
required: false
|
||||||
|
|
2
dist/index.js
generated
vendored
2
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
|
@ -17,6 +17,7 @@ export interface Inputs {
|
||||||
builder: string;
|
builder: string;
|
||||||
'cache-from': string[];
|
'cache-from': string[];
|
||||||
'cache-to': string[];
|
'cache-to': string[];
|
||||||
|
call: string;
|
||||||
'cgroup-parent': string;
|
'cgroup-parent': string;
|
||||||
context: string;
|
context: string;
|
||||||
file: string;
|
file: string;
|
||||||
|
@ -53,6 +54,7 @@ export async function getInputs(): Promise<Inputs> {
|
||||||
builder: core.getInput('builder'),
|
builder: core.getInput('builder'),
|
||||||
'cache-from': Util.getInputList('cache-from', {ignoreComma: true}),
|
'cache-from': Util.getInputList('cache-from', {ignoreComma: true}),
|
||||||
'cache-to': Util.getInputList('cache-to', {ignoreComma: true}),
|
'cache-to': Util.getInputList('cache-to', {ignoreComma: true}),
|
||||||
|
call: core.getInput('call'),
|
||||||
'cgroup-parent': core.getInput('cgroup-parent'),
|
'cgroup-parent': core.getInput('cgroup-parent'),
|
||||||
context: core.getInput('context') || Context.gitContext(),
|
context: core.getInput('context') || Context.gitContext(),
|
||||||
file: core.getInput('file'),
|
file: core.getInput('file'),
|
||||||
|
@ -141,6 +143,12 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit):
|
||||||
await Util.asyncForEach(inputs['cache-to'], async cacheTo => {
|
await Util.asyncForEach(inputs['cache-to'], async cacheTo => {
|
||||||
args.push('--cache-to', cacheTo);
|
args.push('--cache-to', cacheTo);
|
||||||
});
|
});
|
||||||
|
if (inputs.call) {
|
||||||
|
if (!(await toolkit.buildx.versionSatisfies('>=0.15.0'))) {
|
||||||
|
throw new Error(`Buildx >= 0.15.0 is required to use the call flag.`);
|
||||||
|
}
|
||||||
|
args.push('--call', inputs.call);
|
||||||
|
}
|
||||||
if (inputs['cgroup-parent']) {
|
if (inputs['cgroup-parent']) {
|
||||||
args.push('--cgroup-parent', inputs['cgroup-parent']);
|
args.push('--cgroup-parent', inputs['cgroup-parent']);
|
||||||
}
|
}
|
||||||
|
|
12
src/main.ts
12
src/main.ts
|
@ -104,8 +104,14 @@ actionsToolkit.run(
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.exitCode != 0) {
|
||||||
err = Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
|
if (inputs.call && inputs.call === 'check' && res.stdout.length > 0) {
|
||||||
|
// checks warnings are printed to stdout: https://github.com/docker/buildx/pull/2647
|
||||||
|
// take the first line with the message summaryzing the warnings
|
||||||
|
err = Error(res.stdout.split('\n')[0]?.trim());
|
||||||
|
} else if (res.stderr.length > 0) {
|
||||||
|
err = Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -161,6 +167,8 @@ actionsToolkit.run(
|
||||||
await core.group(`Check build summary support`, async () => {
|
await core.group(`Check build summary support`, async () => {
|
||||||
if (!buildSummaryEnabled()) {
|
if (!buildSummaryEnabled()) {
|
||||||
core.info('Build summary disabled');
|
core.info('Build summary disabled');
|
||||||
|
} else if (inputs.call && inputs.call !== 'build') {
|
||||||
|
core.info(`Build summary skipped for ${inputs.call} subrequest`);
|
||||||
} else if (GitHub.isGHES) {
|
} else if (GitHub.isGHES) {
|
||||||
core.info('Build summary is not yet supported on GHES');
|
core.info('Build summary is not yet supported on GHES');
|
||||||
} else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) {
|
} else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) {
|
||||||
|
|
Loading…
Reference in a new issue