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
Copy file name to clipboardExpand all lines: README.md
+34-29Lines changed: 34 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,30 +38,7 @@ ___
38
38
39
39
## Usage
40
40
41
-
By default, this action uses the [Git context](#git-context) so you don't need to use the
42
-
[`actions/checkout`](https://github.com/actions/checkout/) action to checkout the repository because this will be
43
-
done directly by buildkit. The git reference will be based on the [event that triggered your workflow](https://docs.github.com/en/actions/reference/events-that-trigger-workflows)
44
-
and will result in the following context: `https://github.com/<owner>/<repo>.git#<ref>`.
45
-
46
-
You can provide a subdirectory to the [Git context](#git-context) by using the following [Handlebars template](https://handlebarsjs.com/guide/) expression `{{defaultContext}}`:
47
-
48
-
```yaml
49
-
-
50
-
name: Build and push
51
-
id: docker_build
52
-
uses: docker/build-push-action@v2
53
-
with:
54
-
context: {{defaultContext}}:docker
55
-
push: true
56
-
tags: user/app:latest
57
-
```
58
-
59
-
Be careful because **any file mutation in the steps that precede the build step will be ignored, including processing of the `.dockerignore` file** since
60
-
the context is based on the git reference. However, you can use the [Path context](#path-context) using the
61
-
[`context` input](#inputs) alongside the [`actions/checkout`](https://github.com/actions/checkout/) action to remove
62
-
this restriction.
63
-
64
-
In the examples below we are using 3 other actions:
41
+
In the examples below we are also using 3 other actions:
65
42
66
43
*[`setup-buildx`](https://github.com/docker/setup-buildx-action) action will create and boot a builder using by
67
44
default the `docker-container`[builder driver](https://github.com/docker/buildx/blob/master/docs/reference/buildx_create.md#driver).
@@ -72,6 +49,13 @@ to add emulation support with QEMU to be able to build against more platforms.
72
49
73
50
### Git context
74
51
52
+
By default, this action uses the [Git context](#git-context) so you don't need
53
+
to use the [`actions/checkout`](https://github.com/actions/checkout/) action to
54
+
check out the repository because this will be done directly by [BuildKit](https://github.com/moby/buildkit).
55
+
56
+
The git reference will be based on the [event that triggered your workflow](https://docs.github.com/en/actions/reference/events-that-trigger-workflows)
57
+
and will result in the following context: `https://github.com/<owner>/<repo>.git#<ref>`.
58
+
75
59
```yaml
76
60
name: ci
77
61
@@ -98,21 +82,42 @@ jobs:
98
82
password: ${{ secrets.DOCKERHUB_TOKEN }}
99
83
-
100
84
name: Build and push
101
-
id: docker_build
102
85
uses: docker/build-push-action@v2
103
86
with:
104
87
push: true
105
88
tags: user/app:latest
106
89
```
107
90
91
+
Be careful because **any file mutation in the steps that precede the build step
92
+
will be ignored, including processing of the `.dockerignore` file** since
93
+
the context is based on the Git reference. However, you can use the
94
+
[Path context](#path-context) using the [`context` input](#inputs) alongside
95
+
the [`actions/checkout`](https://github.com/actions/checkout/) action to remove
96
+
this restriction.
97
+
98
+
Default Git context can also be provided using the [Handlebars template](https://handlebarsjs.com/guide/)
99
+
expression `{{defaultContext}}`. Here we can use it to provide a subdirectory
100
+
to the default Git context:
101
+
102
+
```yaml
103
+
-
104
+
name: Build and push
105
+
uses: docker/build-push-action@v2
106
+
with:
107
+
context: "{{defaultContext}}:mysubdir"
108
+
push: true
109
+
tags: user/app:latest
110
+
```
111
+
> :warning: Subdirectory for Git context is not yet available for the buildx [`docker` driver](https://github.com/docker/buildx/blob/master/docs/reference/buildx_create.md#driver).
112
+
108
113
Building from the current repository automatically uses the [GitHub Token](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)
109
-
so it does not need to be passed. If you want to authenticate against another private repository, you have to use
110
-
a [secret](docs/advanced/secrets.md) named `GIT_AUTH_TOKEN` to be able to authenticate against it with buildx:
114
+
so it does not need to be passed. If you want to authenticate against another
115
+
private repository, you have to use a [secret](docs/advanced/secrets.md) named
116
+
`GIT_AUTH_TOKEN` to be able to authenticate against it with buildx:
111
117
112
118
```yaml
113
119
-
114
120
name: Build and push
115
-
id: docker_build
116
121
uses: docker/build-push-action@v2
117
122
with:
118
123
push: true
@@ -217,7 +222,7 @@ Following inputs can be used as `step.with` keys
217
222
| `tags` | List/CSV | List of tags |
218
223
| `target` | String | Sets the target stage to build |
219
224
| `ulimit`¹ | List | [Ulimit](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-set-ulimits---ulimit) options (e.g., `nofile=1024:1024`) |
220
-
| `github-token` | String | GitHub Token used to authenticate against a repository for Git context (default `${{ github.token }}`) |
225
+
| `github-token` | String | GitHub Token used to authenticate against a repository for [Git context](#git-context) (default `${{ github.token }}`) |
221
226
222
227
> ¹ `cgroup-parent`, `shm-size` and `ulimit` are only available using `moby/buildkit:master`
Copy file name to clipboardExpand all lines: docs/advanced/tags-labels.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,6 @@
1
1
# Handle tags and labels
2
2
3
-
If you come from [`v1`](https://github.com/docker/build-push-action/tree/releases/v1#readme) and want an
4
-
"automatic" tag management and [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md)
3
+
If you want an "automatic" tag management and [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md)
5
4
for labels, you can do it in a dedicated step. The following workflow will use the [Docker metadata action](https://github.com/docker/metadata-action)
6
5
to handle tags and labels based on GitHub actions events and Git metadata.
0 commit comments