mirror of
https://github.com/docker/build-push-action.git
synced 2025-06-13 14:47:13 +02:00
Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
3e7a4f6646 | |||
79bd2e083d | |||
ab83648e2e | |||
35323d9aa4 | |||
836357fa9e | |||
8e21df3514 | |||
5aca64f130 | |||
7cb863f593 | |||
6115ff08ad | |||
68257a7f8a | |||
92e7146349 | |||
3ff814758e | |||
4ca0e628b9 | |||
abc498d7d3 | |||
13d7e7a55b | |||
e5e36c4a4e | |||
af185b4d18 | |||
57a738dc67 | |||
120f6587bc | |||
434b33a73f | |||
5b676d2d40 |
@ -188,4 +188,4 @@
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
limitations under the License.
|
110
README.md
110
README.md
@ -17,6 +17,7 @@ Suggestions and issues can be posted on the repositories [issues page](https://g
|
||||
* [target](#target)
|
||||
* [always_pull](#always_pull)
|
||||
* [build_args](#build_args)
|
||||
* [cache_froms](#cache_froms)
|
||||
* [labels](#labels)
|
||||
* [add_git_labels](#add_git_labels)
|
||||
* [push](#push)
|
||||
@ -68,6 +69,7 @@ Examples:
|
||||
|Git Reference|Image tag|
|
||||
|---|---|
|
||||
|`refs/heads/master`|`latest`|
|
||||
|`refs/heads/mybranch`|`mybranch`|
|
||||
|`refs/heads/my/branch`|`my-branch`|
|
||||
|`refs/pull/2/merge`|`pr-2-merge`|
|
||||
|`refs/tags/v1.0.0`|`v1.0.0`|
|
||||
@ -86,11 +88,13 @@ Example:
|
||||
|
||||
### `path`
|
||||
|
||||
Path to run the docker build from. Defaults to `.`.
|
||||
Path to the build context. Defaults to `.`
|
||||
|
||||
### `dockerfile`
|
||||
|
||||
Name of the Dockerfile. Defaults to `{path}/Dockerfile`.
|
||||
Path to the Dockerfile. Defaults to `{path}/Dockerfile`
|
||||
|
||||
Note when set this path is **not** relative to the `path` input but is instead relative to the current working directory.
|
||||
|
||||
### `target`
|
||||
|
||||
@ -112,6 +116,15 @@ Example:
|
||||
build_args: arg1=value1,arg2=value2
|
||||
```
|
||||
|
||||
### `cache_froms`
|
||||
|
||||
Comma-delimited list of images to consider as cache sources.
|
||||
|
||||
Example:
|
||||
```yaml
|
||||
cache_froms: myorg/baseimage:latest
|
||||
```
|
||||
|
||||
### `labels`
|
||||
|
||||
Comma-delimited list of labels to add to the built image.
|
||||
@ -148,46 +161,83 @@ Whether to push the built image.
|
||||
The following will build the root Dockerfile, tag the image as `myorg/myrepository:latest`, log in to Docker Hub using GitHub secrets, and push the image to the Docker Hub repository `myorg/myrepository`:
|
||||
|
||||
```yaml
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
repository: myorg/myrepository
|
||||
tags: latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build and push Docker images
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
repository: myorg/myrepository
|
||||
tags: latest
|
||||
```
|
||||
|
||||
The following will build the root Dockerfile, tag the image with the git reference and SHA as described above, log in to Docker Hub using GitHub secrets, and push the image to the Docker Hub repository `myorg/myrepository`:
|
||||
|
||||
```yaml
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
repository: myorg/myrepository
|
||||
tag_with_ref: true
|
||||
tag_with_sha: true
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build and push Docker images
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
repository: myorg/myrepository
|
||||
tag_with_ref: true
|
||||
tag_with_sha: true
|
||||
```
|
||||
|
||||
The following will only push the image when the event that kicked off the workflow was a push of a git tag:
|
||||
|
||||
```yaml
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
repository: myorg/myrepository
|
||||
tag_with_ref: true
|
||||
push: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build and push Docker images
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
repository: myorg/myrepository
|
||||
tag_with_ref: true
|
||||
push: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
```
|
||||
|
||||
The following builds the `mytarget` stage and pushes that:
|
||||
|
||||
```yaml
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
repository: myorg/myrepository
|
||||
tag_with_ref: true
|
||||
target: mytarget
|
||||
```
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build and push Docker images
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
repository: myorg/myrepository
|
||||
tag_with_ref: true
|
||||
target: mytarget
|
||||
```
|
||||
|
||||
The following will build the root Dockerfile, tag the image as `myorg/myrepository:latest`, log in to Google Container Registry using GitHub secrets (where `DOCKER_PASSWORD` is a [JSON key](https://cloud.google.com/container-registry/docs/advanced-authentication#json-key)), and push the image to the GCR repository `myorg/myrepository`:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build and push Docker images
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: _json_key
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: gcr.io
|
||||
repository: myorg/myrepository
|
||||
tags: latest
|
||||
```
|
||||
|
10
action.yml
10
action.yml
@ -6,7 +6,7 @@ branding:
|
||||
color: 'blue'
|
||||
runs:
|
||||
using: docker
|
||||
image: docker://docker/github-actions:v1.0
|
||||
image: docker://docker/github-actions:v1
|
||||
args:
|
||||
- build-push
|
||||
inputs:
|
||||
@ -20,6 +20,7 @@ inputs:
|
||||
description: Server address of Docker registry. If not set then will default to Docker Hub
|
||||
required: false
|
||||
repository:
|
||||
deprecationMessage: 'v2 is now available through docker/build-push-action@v2'
|
||||
description: Docker repository to tag the image with
|
||||
required: true
|
||||
tags:
|
||||
@ -34,11 +35,11 @@ inputs:
|
||||
required: false
|
||||
default: false
|
||||
path:
|
||||
description: Path to run docker build from
|
||||
description: Path to the build context
|
||||
required: false
|
||||
default: "."
|
||||
dockerfile:
|
||||
description: Name of the Dockerfile (Default is 'path/Dockerfile')
|
||||
description: Path to the Dockerfile (Default is '{path}/Dockerfile')
|
||||
required: false
|
||||
target:
|
||||
description: Sets the target stage to build
|
||||
@ -50,6 +51,9 @@ inputs:
|
||||
build_args:
|
||||
description: Comma-delimited list of build-time variables
|
||||
required: false
|
||||
cache_froms:
|
||||
description: Comma-delimited list of images to consider as cache sources
|
||||
required: false
|
||||
labels:
|
||||
description: Comma-delimited list of labels to add to the built image
|
||||
required: false
|
||||
|
Reference in New Issue
Block a user