Skip to content

Commit 8e21df3

Browse files
authored
Merge pull request #75 from rcorrear/patch-1
Update README.md
2 parents 7cb863f + 5aca64f commit 8e21df3

File tree

1 file changed

+59
-34
lines changed

1 file changed

+59
-34
lines changed

README.md

Lines changed: 59 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -160,58 +160,83 @@ Whether to push the built image.
160160
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`:
161161

162162
```yaml
163-
uses: docker/build-push-action@v1
164-
with:
165-
username: ${{ secrets.DOCKER_USERNAME }}
166-
password: ${{ secrets.DOCKER_PASSWORD }}
167-
repository: myorg/myrepository
168-
tags: latest
163+
steps:
164+
- name: Checkout code
165+
uses: actions/checkout@v2
166+
167+
- name: Build and push Docker images
168+
uses: docker/build-push-action@v1
169+
with:
170+
username: ${{ secrets.DOCKER_USERNAME }}
171+
password: ${{ secrets.DOCKER_PASSWORD }}
172+
repository: myorg/myrepository
173+
tags: latest
169174
```
170175

171176
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`:
172177

173178
```yaml
174-
uses: docker/build-push-action@v1
175-
with:
176-
username: ${{ secrets.DOCKER_USERNAME }}
177-
password: ${{ secrets.DOCKER_PASSWORD }}
178-
repository: myorg/myrepository
179-
tag_with_ref: true
180-
tag_with_sha: true
179+
steps:
180+
- name: Checkout code
181+
uses: actions/checkout@v2
182+
183+
- name: Build and push Docker images
184+
uses: docker/build-push-action@v1
185+
with:
186+
username: ${{ secrets.DOCKER_USERNAME }}
187+
password: ${{ secrets.DOCKER_PASSWORD }}
188+
repository: myorg/myrepository
189+
tag_with_ref: true
190+
tag_with_sha: true
181191
```
182192

183193
The following will only push the image when the event that kicked off the workflow was a push of a git tag:
184194

185195
```yaml
186-
uses: docker/build-push-action@v1
187-
with:
188-
username: ${{ secrets.DOCKER_USERNAME }}
189-
password: ${{ secrets.DOCKER_PASSWORD }}
190-
repository: myorg/myrepository
191-
tag_with_ref: true
192-
push: ${{ startsWith(github.ref, 'refs/tags/') }}
196+
steps:
197+
- name: Checkout code
198+
uses: actions/checkout@v2
199+
200+
- name: Build and push Docker images
201+
uses: docker/build-push-action@v1
202+
with:
203+
username: ${{ secrets.DOCKER_USERNAME }}
204+
password: ${{ secrets.DOCKER_PASSWORD }}
205+
repository: myorg/myrepository
206+
tag_with_ref: true
207+
push: ${{ startsWith(github.ref, 'refs/tags/') }}
193208
```
194209

195210
The following builds the `mytarget` stage and pushes that:
196211

197212
```yaml
198-
uses: docker/build-push-action@v1
199-
with:
200-
username: ${{ secrets.DOCKER_USERNAME }}
201-
password: ${{ secrets.DOCKER_PASSWORD }}
202-
repository: myorg/myrepository
203-
tag_with_ref: true
204-
target: mytarget
213+
steps:
214+
- name: Checkout code
215+
uses: actions/checkout@v2
216+
217+
- name: Build and push Docker images
218+
uses: docker/build-push-action@v1
219+
with:
220+
username: ${{ secrets.DOCKER_USERNAME }}
221+
password: ${{ secrets.DOCKER_PASSWORD }}
222+
repository: myorg/myrepository
223+
tag_with_ref: true
224+
target: mytarget
205225
```
206226

207227
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`:
208228

209229
```yaml
210-
uses: docker/build-push-action@v1
211-
with:
212-
username: _json_key
213-
password: ${{ secrets.DOCKER_PASSWORD }}
214-
registry: gcr.io
215-
repository: myorg/myrepository
216-
tags: latest
230+
steps:
231+
- name: Checkout code
232+
uses: actions/checkout@v2
233+
234+
- name: Build and push Docker images
235+
uses: docker/build-push-action@v1
236+
with:
237+
username: _json_key
238+
password: ${{ secrets.DOCKER_PASSWORD }}
239+
registry: gcr.io
240+
repository: myorg/myrepository
241+
tags: latest
217242
```

0 commit comments

Comments
 (0)