Skip to content

Commit d0931a7

Browse files
authored
Merge pull request #455 from crazy-max/doc
Test before pushing your image (docs)
2 parents a66e35b + 326ec1e commit d0931a7

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ ___
3636
* [Local registry](docs/advanced/local-registry.md)
3737
* [Export image to Docker](docs/advanced/export-docker.md)
3838
* [Share built image between jobs](docs/advanced/share-image-jobs.md)
39+
* [Test your image before pushing it](docs/advanced/test-before-push.md)
3940
* [Handle tags and labels](docs/advanced/tags-labels.md)
4041
* [Update DockerHub repo description](docs/advanced/dockerhub-desc.md)
4142
* [Customizing](#customizing)
@@ -165,6 +166,7 @@ jobs:
165166
* [Local registry](docs/advanced/local-registry.md)
166167
* [Export image to Docker](docs/advanced/export-docker.md)
167168
* [Share built image between jobs](docs/advanced/share-image-jobs.md)
169+
* [Test your image before pushing it](docs/advanced/test-before-push.md)
168170
* [Handle tags and labels](docs/advanced/tags-labels.md)
169171
* [Update DockerHub repo description](docs/advanced/dockerhub-desc.md)
170172

docs/advanced/test-before-push.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Test your image before pushing it
2+
3+
In some cases, you might want to validate that the image works as expected
4+
before pushing it.
5+
6+
The workflow below will be composed of several steps to achieve this:
7+
* Build and export the image to Docker
8+
* Test your image
9+
* Multi-platform build and push the image
10+
11+
```yaml
12+
name: ci
13+
14+
on:
15+
push:
16+
branches:
17+
- 'master'
18+
19+
env:
20+
TEST_TAG: user/myapp:test
21+
22+
jobs:
23+
docker:
24+
runs-on: ubuntu-latest
25+
steps:
26+
-
27+
name: Checkout
28+
uses: actions/checkout@v2
29+
-
30+
name: Set up QEMU
31+
uses: docker/setup-qemu-action@v1
32+
-
33+
name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v1
35+
-
36+
name: Login to DockerHub
37+
uses: docker/login-action@v1
38+
with:
39+
username: ${{ secrets.DOCKERHUB_USERNAME }}
40+
password: ${{ secrets.DOCKERHUB_TOKEN }}
41+
-
42+
name: Build and export to Docker
43+
uses: docker/build-push-action@v2
44+
with:
45+
context: .
46+
load: true
47+
tags: ${{ env.TEST_TAG }}
48+
-
49+
name: Test
50+
run: |
51+
docker run --rm ${{ env.TEST_TAG }}
52+
-
53+
name: Build and push
54+
uses: docker/build-push-action@v2
55+
with:
56+
context: .
57+
platforms: linux/amd64,linux/arm64
58+
push: true
59+
tags: user/app:latest
60+
```
61+
62+
> :bulb: Build time will not be increased with this workflow because internal
63+
> cache for `linux/amd64` will be used from previous step on `Build and push`
64+
> step so only `linux/arm64` will be actually built.

0 commit comments

Comments
 (0)