You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -56,7 +57,8 @@ build-secrets, remote cache, etc. and different builder deployment/namespacing o
56
57
57
58
### Git context
58
59
59
-
The default behavior of this action is to use the [Git context invoked by your workflow](https://github.com/docker/build-push-action/blob/master/src/context.ts#L31-L35).
60
+
The default behavior of this action is to use the [Git context invoked](https://github.com/docker/build-push-action/blob/master/src/context.ts#L31-L35)
61
+
by your workflow.
60
62
61
63
```yaml
62
64
name: ci
@@ -380,6 +382,46 @@ For testing purposes you may need to create a [local registry](https://hub.docke
380
382
```
381
383
</details>
382
384
385
+
### Export image to Docker
386
+
387
+
You may want your build result to be available in the Docker client through `docker images` to be able to use it
388
+
in another step of your workflow:
389
+
390
+
<details>
391
+
<summary><b>Show workflow</b></summary>
392
+
393
+
```yaml
394
+
name: ci
395
+
396
+
on:
397
+
push:
398
+
branches: master
399
+
400
+
jobs:
401
+
export-docker:
402
+
runs-on: ubuntu-latest
403
+
steps:
404
+
-
405
+
name: Checkout
406
+
uses: actions/checkout@v2
407
+
-
408
+
name: Set up Docker Buildx
409
+
uses: docker/setup-buildx-action@v1
410
+
-
411
+
name: Build
412
+
uses: docker/build-push-action@v2
413
+
with:
414
+
context: .
415
+
file: ./Dockerfile
416
+
load: true
417
+
tags: myimage:latest
418
+
-
419
+
name: Inspect
420
+
run: |
421
+
docker image inspect myimage:latest
422
+
```
423
+
</details>
424
+
383
425
### Leverage GitHub cache
384
426
385
427
You can leverage [GitHub cache](https://docs.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows)
@@ -427,15 +469,20 @@ using [actions/cache](https://github.com/actions/cache) with this action:
427
469
```
428
470
</details>
429
471
472
+
> If you want to [export layers for all stages](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue),
473
+
> you have to specify `mode=max` attribute in `cache-to`.
474
+
430
475
### Complete workflow
431
476
432
-
If you come from [`v1`](https://github.com/docker/build-push-action/tree/releases/v1#readme) and you want an
477
+
If you come from [`v1`](https://github.com/docker/build-push-action/tree/releases/v1#readme) and want an
433
478
"automatic"tag management through Git reference and [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md)
434
-
for labels, you will have to do it in a dedicated step [for now](https://github.com/docker/build-push-action/issues/116).
479
+
for labels, you will have to do it in a dedicated step.
435
480
436
481
The following workflow with the `Prepare` step will generate some [outputs](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjobs_idoutputs)
437
-
to handle tags and labels based on GitHub actions events. This is just an example to show many cases that you
438
-
might want to use:
482
+
to handle tags and labels based on GitHub actions events.
483
+
484
+
This is just an example to show many cases that you might want to use and that you will have to adapt according
@@ -615,18 +674,6 @@ Following inputs can be used as `step.with` keys
615
674
| `cache-to` | List | List of [cache export destinations](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue) (eg. `type=local,dest=path/to/dir`) |
616
675
| `secrets` | List | List of secrets to expose to the build (eg. `key=value`, `GIT_AUTH_TOKEN=mytoken`) |
0 commit comments