mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-23 11:29:02 +00:00
Update README.md
Add checkout step to examples. Signed-off-by: Ricardo Correa <r.correa.r@gmail.com>
This commit is contained in:
parent
7cb863f593
commit
5aca64f130
93
README.md
93
README.md
@ -160,58 +160,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`:
|
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
|
```yaml
|
||||||
uses: docker/build-push-action@v1
|
steps:
|
||||||
with:
|
- name: Checkout code
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
uses: actions/checkout@v2
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
repository: myorg/myrepository
|
- name: Build and push Docker images
|
||||||
tags: latest
|
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`:
|
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
|
```yaml
|
||||||
uses: docker/build-push-action@v1
|
steps:
|
||||||
with:
|
- name: Checkout code
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
uses: actions/checkout@v2
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
repository: myorg/myrepository
|
- name: Build and push Docker images
|
||||||
tag_with_ref: true
|
uses: docker/build-push-action@v1
|
||||||
tag_with_sha: true
|
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:
|
The following will only push the image when the event that kicked off the workflow was a push of a git tag:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
uses: docker/build-push-action@v1
|
steps:
|
||||||
with:
|
- name: Checkout code
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
uses: actions/checkout@v2
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
repository: myorg/myrepository
|
- name: Build and push Docker images
|
||||||
tag_with_ref: true
|
uses: docker/build-push-action@v1
|
||||||
push: ${{ startsWith(github.ref, 'refs/tags/') }}
|
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:
|
The following builds the `mytarget` stage and pushes that:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
uses: docker/build-push-action@v1
|
steps:
|
||||||
with:
|
- name: Checkout code
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
uses: actions/checkout@v2
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
repository: myorg/myrepository
|
- name: Build and push Docker images
|
||||||
tag_with_ref: true
|
uses: docker/build-push-action@v1
|
||||||
target: mytarget
|
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`:
|
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
|
```yaml
|
||||||
uses: docker/build-push-action@v1
|
steps:
|
||||||
with:
|
- name: Checkout code
|
||||||
username: _json_key
|
uses: actions/checkout@v2
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
registry: gcr.io
|
- name: Build and push Docker images
|
||||||
repository: myorg/myrepository
|
uses: docker/build-push-action@v1
|
||||||
tags: latest
|
with:
|
||||||
|
username: _json_key
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
registry: gcr.io
|
||||||
|
repository: myorg/myrepository
|
||||||
|
tags: latest
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user