mirror of
https://github.com/docker/build-push-action.git
synced 2026-01-13 16:03:06 +08:00
Compare commits
1 Commits
c333dfd43d
...
b1877030c1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1877030c1 |
32
.github/workflows/ci.yml
vendored
32
.github/workflows/ci.yml
vendored
@ -288,6 +288,7 @@ 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
|
||||||
@ -323,6 +324,7 @@ 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
|
||||||
@ -1509,33 +1511,3 @@ 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
|
|
||||||
|
|||||||
21
.github/workflows/publish.yml
vendored
21
.github/workflows/publish.yml
vendored
@ -1,21 +0,0 @@
|
|||||||
name: publish
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types:
|
|
||||||
- published
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
id-token: write
|
|
||||||
packages: write
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
-
|
|
||||||
name: Publish
|
|
||||||
uses: actions/publish-immutable-action@v0.0.4
|
|
||||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
|||||||
targets: test
|
targets: test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@v5
|
uses: codecov/codecov-action@v4
|
||||||
with:
|
with:
|
||||||
files: ./coverage/clover.xml
|
file: ./coverage/clover.xml
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|||||||
@ -220,7 +220,6 @@ 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`) |
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
* [BuildKit container logs](#buildkit-container-logs)
|
* [BuildKit container logs](#buildkit-container-logs)
|
||||||
* [With containerd](#with-containerd)
|
* [With containerd](#with-containerd)
|
||||||
* [`repository name must be lowercase`](#repository-name-must-be-lowercase)
|
* [`repository name must be lowercase`](#repository-name-must-be-lowercase)
|
||||||
|
* [Image not loaded](#image-not-loaded)
|
||||||
|
|
||||||
## Cannot push to a registry
|
## Cannot push to a registry
|
||||||
|
|
||||||
@ -135,3 +136,29 @@ Or a dedicated step to sanitize the slug:
|
|||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.repo_slug.outputs.result }}:latest
|
tags: ${{ steps.repo_slug.outputs.result }}:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Image not loaded
|
||||||
|
|
||||||
|
Sometimes when your workflows are heavy consumers of disk storage, it can happen that build-push-action declares that the built image is loaded, but then not found in the following workflow steps.
|
||||||
|
|
||||||
|
- You can use the following solution as workaround, to free space on disk before building docker image using the following workflow step
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# Free disk space
|
||||||
|
- name: Free Disk space
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
|
||||||
|
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
|
||||||
|
```
|
||||||
|
|
||||||
|
- Another workaround can be to call `docker/setup-buildx-action` with docker driver
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
driver: docker
|
||||||
|
```
|
||||||
|
|
||||||
|
More details in the [related issue](https://github.com/docker/build-push-action/issues/321)
|
||||||
|
|||||||
@ -34,9 +34,6 @@ 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
|
||||||
|
|||||||
30
dist/index.js
generated
vendored
30
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,7 +17,6 @@ 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;
|
||||||
@ -54,7 +53,6 @@ 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'),
|
||||||
@ -117,9 +115,9 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit):
|
|||||||
await Util.asyncForEach(inputs['add-hosts'], async addHost => {
|
await Util.asyncForEach(inputs['add-hosts'], async addHost => {
|
||||||
args.push('--add-host', addHost);
|
args.push('--add-host', addHost);
|
||||||
});
|
});
|
||||||
await Util.asyncForEach(inputs.allow, async allow => {
|
if (inputs.allow.length > 0) {
|
||||||
args.push('--allow', allow);
|
args.push('--allow', inputs.allow.join(','));
|
||||||
});
|
}
|
||||||
if (await toolkit.buildx.versionSatisfies('>=0.12.0')) {
|
if (await toolkit.buildx.versionSatisfies('>=0.12.0')) {
|
||||||
await Util.asyncForEach(inputs.annotations, async annotation => {
|
await Util.asyncForEach(inputs.annotations, async annotation => {
|
||||||
args.push('--annotation', annotation);
|
args.push('--annotation', annotation);
|
||||||
@ -143,12 +141,6 @@ 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,14 +104,8 @@ actionsToolkit.run(
|
|||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.exitCode != 0) {
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
if (inputs.call && inputs.call === 'check' && res.stdout.length > 0) {
|
err = Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
|
||||||
// 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'}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -167,8 +161,6 @@ 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'))) {
|
||||||
|
|||||||
@ -3035,13 +3035,13 @@ __metadata:
|
|||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3":
|
"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3":
|
||||||
version: 7.0.6
|
version: 7.0.3
|
||||||
resolution: "cross-spawn@npm:7.0.6"
|
resolution: "cross-spawn@npm:7.0.3"
|
||||||
dependencies:
|
dependencies:
|
||||||
path-key: ^3.1.0
|
path-key: ^3.1.0
|
||||||
shebang-command: ^2.0.0
|
shebang-command: ^2.0.0
|
||||||
which: ^2.0.1
|
which: ^2.0.1
|
||||||
checksum: 8d306efacaf6f3f60e0224c287664093fa9185680b2d195852ba9a863f85d02dcc737094c6e512175f8ee0161f9b87c73c6826034c2422e39de7d6569cf4503b
|
checksum: 671cc7c7288c3a8406f3c69a3ae2fc85555c04169e9d611def9a675635472614f1c0ed0ef80955d5b6d4e724f6ced67f0ad1bb006c2ea643488fcfef994d7f52
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user