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
+59-34Lines changed: 59 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,58 +160,83 @@ Whether to push the built image.
160
160
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`:
161
161
162
162
```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
169
174
```
170
175
171
176
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`:
172
177
173
178
```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
181
191
```
182
192
183
193
The following will only push the image when the event that kicked off the workflow was a push of a git tag:
184
194
185
195
```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/') }}
193
208
```
194
209
195
210
The following builds the `mytarget` stage and pushes that:
196
211
197
212
```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
205
225
```
206
226
207
227
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`:
0 commit comments