Skip to content

Commit 5ffbca1

Browse files
committed
no-cache-filters input
Signed-off-by: CrazyMax <[email protected]>
1 parent a8d76c0 commit 5ffbca1

File tree

7 files changed

+73
-42
lines changed

7 files changed

+73
-42
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ jobs:
310310
name: Set up Docker Buildx
311311
uses: docker/setup-buildx-action@v2
312312
with:
313-
version: v0.7.0
314313
driver-opts: |
315314
image=moby/buildkit:master
316315
-
@@ -332,7 +331,6 @@ jobs:
332331
name: Set up Docker Buildx
333332
uses: docker/setup-buildx-action@v2
334333
with:
335-
version: v0.7.0
336334
driver-opts: |
337335
image=moby/buildkit:master
338336
-
@@ -356,7 +354,6 @@ jobs:
356354
name: Set up Docker Buildx
357355
uses: docker/setup-buildx-action@v2
358356
with:
359-
version: v0.7.0
360357
driver-opts: |
361358
image=moby/buildkit:master
362359
-
@@ -397,8 +394,6 @@ jobs:
397394
-
398395
name: Set up Docker Buildx
399396
uses: docker/setup-buildx-action@v2
400-
with:
401-
version: v0.8.0
402397
-
403398
name: Build
404399
uses: ./
@@ -409,6 +404,26 @@ jobs:
409404
alpine=docker-image://debian:stable-slim
410405
tags: name/app:latest
411406

407+
no-cache-filters:
408+
runs-on: ubuntu-latest
409+
steps:
410+
-
411+
name: Checkout
412+
uses: actions/checkout@v3
413+
-
414+
name: Set up Docker Buildx
415+
uses: docker/setup-buildx-action@v2
416+
-
417+
name: Build
418+
uses: ./
419+
with:
420+
context: ./test
421+
file: ./test/nocachefilter.Dockerfile
422+
no-cache-filters: build
423+
tags: name/app:latest
424+
cache-from: type=gha,scope=nocachefilter
425+
cache-to: type=gha,scope=nocachefilter,mode=max
426+
412427
multi:
413428
runs-on: ubuntu-latest
414429
strategy:
@@ -506,7 +521,6 @@ jobs:
506521
name: Set up Docker Buildx
507522
uses: docker/setup-buildx-action@v2
508523
with:
509-
version: v0.8.0
510524
driver: ${{ matrix.driver }}
511525
driver-opts: |
512526
network=host

README.md

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -197,44 +197,45 @@ Following inputs can be used as `step.with` keys
197197
> tags: name/app:latest,name/app:1.0.0
198198
> ```
199199

200-
| Name | Type | Description |
201-
|---------------------|----------|------------------------------------|
202-
| `add-hosts` | List/CSV | List of [customs host-to-IP mapping](https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file---add-host) (e.g., `docker:10.180.0.1`) |
203-
| `allow` | List/CSV | List of [extra privileged entitlement](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#allow) (e.g., `network.host,security.insecure`) |
204-
| `builder` | String | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) |
205-
| `build-args` | List | List of [build-time variables](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#build-arg) |
206-
| `build-contexts` | List | List of additional [build contexts](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#build-context) (e.g., `name=path`) |
207-
| `cache-from` | List | List of [external cache sources](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#cache-from) (e.g., `type=local,src=path/to/dir`) |
208-
| `cache-to` | List | List of [cache export destinations](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#cache-to) (e.g., `type=local,dest=path/to/dir`) |
209-
| `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 |
210-
| `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)) |
211-
| `file` | String | Path to the Dockerfile. (default `{context}/Dockerfile`) |
212-
| `labels` | List | List of metadata for an image |
213-
| `load` | Bool | [Load](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#load) is a shorthand for `--output=type=docker` (default `false`) |
214-
| `network` | String | Set the networking mode for the `RUN` instructions during build |
215-
| `no-cache` | Bool | Do not use cache when building the image (default `false`) |
216-
| `outputs` | List | List of [output destinations](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#output) (format: `type=local,dest=path`) |
217-
| `platforms` | List/CSV | List of [target platforms](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#platform) for build |
218-
| `pull` | Bool | Always attempt to pull all referenced images (default `false`) |
219-
| `push` | Bool | [Push](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#push) is a shorthand for `--output=type=registry` (default `false`) |
220-
| `secrets` | List | List of [secrets](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#secret) to expose to the build (e.g., `key=string`, `GIT_AUTH_TOKEN=mytoken`) |
221-
| `secret-files` | List | List of [secret files](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#secret) to expose to the build (e.g., `key=filename`, `MY_SECRET=./secret.txt`) |
222-
| `shm-size` | String | Size of [`/dev/shm`](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-size-of-devshm---shm-size) (e.g., `2g`) |
223-
| `ssh` | List | List of [SSH agent socket or keys](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#ssh) to expose to the build |
224-
| `tags` | List/CSV | List of tags |
225-
| `target` | String | Sets the target stage to build |
226-
| `ulimit` | List | [Ulimit](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-set-ulimits---ulimit) options (e.g., `nofile=1024:1024`) |
227-
| `github-token` | String | GitHub Token used to authenticate against a repository for [Git context](#git-context) (default `${{ github.token }}`) |
200+
| Name | Type | Description |
201+
|--------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
202+
| `add-hosts` | List/CSV | List of [customs host-to-IP mapping](https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file---add-host) (e.g., `docker:10.180.0.1`) |
203+
| `allow` | List/CSV | List of [extra privileged entitlement](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#allow) (e.g., `network.host,security.insecure`) |
204+
| `builder` | String | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) |
205+
| `build-args` | List | List of [build-time variables](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#build-arg) |
206+
| `build-contexts` | List | List of additional [build contexts](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#build-context) (e.g., `name=path`) |
207+
| `cache-from` | List | List of [external cache sources](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#cache-from) (e.g., `type=local,src=path/to/dir`) |
208+
| `cache-to` | List | List of [cache export destinations](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#cache-to) (e.g., `type=local,dest=path/to/dir`) |
209+
| `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 |
210+
| `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)) |
211+
| `file` | String | Path to the Dockerfile. (default `{context}/Dockerfile`) |
212+
| `labels` | List | List of metadata for an image |
213+
| `load` | Bool | [Load](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#load) is a shorthand for `--output=type=docker` (default `false`) |
214+
| `network` | String | Set the networking mode for the `RUN` instructions during build |
215+
| `no-cache` | Bool | Do not use cache when building the image (default `false`) |
216+
| `no-cache-filters` | List/CSV | Do not cache specified stages |
217+
| `outputs` | List | List of [output destinations](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#output) (format: `type=local,dest=path`) |
218+
| `platforms` | List/CSV | List of [target platforms](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#platform) for build |
219+
| `pull` | Bool | Always attempt to pull all referenced images (default `false`) |
220+
| `push` | Bool | [Push](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#push) is a shorthand for `--output=type=registry` (default `false`) |
221+
| `secrets` | List | List of [secrets](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#secret) to expose to the build (e.g., `key=string`, `GIT_AUTH_TOKEN=mytoken`) |
222+
| `secret-files` | List | List of [secret files](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#secret) to expose to the build (e.g., `key=filename`, `MY_SECRET=./secret.txt`) |
223+
| `shm-size` | String | Size of [`/dev/shm`](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-size-of-devshm---shm-size) (e.g., `2g`) |
224+
| `ssh` | List | List of [SSH agent socket or keys](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#ssh) to expose to the build |
225+
| `tags` | List/CSV | List of tags |
226+
| `target` | String | Sets the target stage to build |
227+
| `ulimit` | List | [Ulimit](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-set-ulimits---ulimit) options (e.g., `nofile=1024:1024`) |
228+
| `github-token` | String | GitHub Token used to authenticate against a repository for [Git context](#git-context) (default `${{ github.token }}`) |
228229

229230
### outputs
230231

231232
Following outputs are available
232233

233-
| Name | Type | Description |
234-
|-------------------|---------|---------------------------------------|
235-
| `imageid` | String | Image ID |
236-
| `digest` | String | Image digest |
237-
| `metadata` | JSON | Build result metadata |
234+
| Name | Type | Description |
235+
|------------|---------|-----------------------------------------|
236+
| `imageid` | String | Image ID |
237+
| `digest` | String | Image digest |
238+
| `metadata` | JSON | Build result metadata |
238239

239240
## Troubleshooting
240241

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ inputs:
5151
description: "Do not use cache when building the image"
5252
required: false
5353
default: 'false'
54+
no-cache-filters:
55+
description: "Do not cache specified stages"
56+
required: false
5457
outputs:
5558
description: "List of output destinations (format: type=local,dest=path)"
5659
required: false

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface Inputs {
2828
load: boolean;
2929
network: string;
3030
noCache: boolean;
31+
noCacheFilters: string[];
3132
outputs: string[];
3233
platforms: string[];
3334
pull: boolean;
@@ -83,6 +84,7 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
8384
load: core.getBooleanInput('load'),
8485
network: core.getInput('network'),
8586
noCache: core.getBooleanInput('no-cache'),
87+
noCacheFilters: await getInputList('no-cache-filters'),
8688
outputs: await getInputList('outputs', true),
8789
platforms: await getInputList('platforms'),
8890
pull: core.getBooleanInput('pull'),
@@ -141,6 +143,9 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
141143
await asyncForEach(inputs.labels, async label => {
142144
args.push('--label', label);
143145
});
146+
await asyncForEach(inputs.noCacheFilters, async noCacheFilter => {
147+
args.push('--no-cache-filter', noCacheFilter);
148+
});
144149
await asyncForEach(inputs.outputs, async output => {
145150
args.push('--output', output);
146151
});

test/nocachefilter.Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM busybox AS base
2+
RUN echo "Hello world!" > /hello
3+
4+
FROM alpine AS build
5+
COPY --from=base /hello /hello
6+
RUN uname -a
7+
8+
FROM build

0 commit comments

Comments
 (0)