Skip to content

Commit 5b4307d

Browse files
authored
Merge pull request #198 from crazy-max/update-readme
Improve README
2 parents 99ba0e6 + 28262c0 commit 5b4307d

File tree

2 files changed

+89
-19
lines changed

2 files changed

+89
-19
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,29 @@ jobs:
255255
if: always()
256256
uses: crazy-max/ghaction-dump-context@v1
257257

258+
export-docker:
259+
runs-on: ubuntu-latest
260+
steps:
261+
-
262+
name: Checkout
263+
uses: actions/checkout@v2.3.3
264+
-
265+
name: Build
266+
uses: ./
267+
with:
268+
context: ./test
269+
file: ./test/Dockerfile
270+
load: true
271+
tags: myimage:latest
272+
-
273+
name: Inspect
274+
run: |
275+
docker image inspect myimage:latest
276+
-
277+
name: Dump context
278+
if: always()
279+
uses: crazy-max/ghaction-dump-context@v1
280+
258281
multi:
259282
runs-on: ubuntu-latest
260283
strategy:

README.md

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
## Upgrade from v1
88

99
`v2` of this action includes significant updates and now uses Docker [Buildx](https://github.com/docker/buildx). It
10-
works with 3 new optional actions ([login](https://github.com/docker/login-action), [setup-buildx](https://github.com/docker/setup-buildx-action)
10+
works with 3 new actions ([login](https://github.com/docker/login-action), [setup-buildx](https://github.com/docker/setup-buildx-action)
1111
and [setup-qemu](https://github.com/docker/setup-qemu-action)) that we have created. It's also rewritten as a
1212
[typescript-action](https://github.com/actions/typescript-action/) to be as closed as possible of the
13-
[GitHub Runner](https://github.com/actions/virtual-environments) during its execution (#71 #92).
13+
[GitHub Runner](https://github.com/actions/virtual-environments) during its execution.
1414

1515
[Upgrade notes](UPGRADE.md) and many [usage examples](#usage) have been added to handle most use cases but `v1` is
1616
still available through [`releases/v1` branch](https://github.com/docker/build-push-action/tree/releases/v1).
@@ -37,6 +37,7 @@ ___
3737
* [Push to multi-registries](#push-to-multi-registries)
3838
* [Cache to registry](#push-to-multi-registries)
3939
* [Local registry](#local-registry)
40+
* [Export image to Docker](#export-image-to-docker)
4041
* [Leverage GitHub cache](#leverage-github-cache)
4142
* [Complete workflow](#complete-workflow)
4243
* [Update DockerHub repo description](#update-dockerhub-repo-description)
@@ -56,7 +57,8 @@ build-secrets, remote cache, etc. and different builder deployment/namespacing o
5657

5758
### Git context
5859

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.
6062

6163
```yaml
6264
name: ci
@@ -380,6 +382,46 @@ For testing purposes you may need to create a [local registry](https://hub.docke
380382
```
381383
</details>
382384

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+
383425
### Leverage GitHub cache
384426

385427
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:
427469
```
428470
</details>
429471

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+
430475
### Complete workflow
431476

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
433478
"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.
435480

436481
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
485+
to your needs:
439486

440487
<details>
441488
<summary><b>Show workflow</b></summary>
@@ -595,6 +642,18 @@ with this action:
595642

596643
Following inputs can be used as `step.with` keys
597644

645+
> `List` type is a newline-delimited string
646+
> ```yaml
647+
> cache-from: |
648+
> user/app:cache
649+
> type=local,src=path/to/dir
650+
> ```
651+
652+
> `CSV` type is a comma-delimited string
653+
> ```yaml
654+
> tags: name/app:latest,name/app:1.0.0
655+
> ```
656+
598657
| Name | Type | Description |
599658
|---------------------|----------|------------------------------------|
600659
| `builder` | String | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) |
@@ -615,18 +674,6 @@ Following inputs can be used as `step.with` keys
615674
| `cache-to` | List | List of [cache export destinations](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue) (eg. `type=local,dest=path/to/dir`) |
616675
| `secrets` | List | List of secrets to expose to the build (eg. `key=value`, `GIT_AUTH_TOKEN=mytoken`) |
617676

618-
> `List` type is a newline-delimited string
619-
> ```yaml
620-
> cache-from: |
621-
> user/app:cache
622-
> type=local,src=path/to/dir
623-
> ```
624-
625-
> `CSV` type is a comma-delimited string
626-
> ```yaml
627-
> tags: name/app:latest,name/app:1.0.0
628-
> ```
629-
630677
### outputs
631678

632679
Following outputs are available

0 commit comments

Comments
 (0)