Skip to content

Commit 95f9975

Browse files
authored
Merge pull request #362 from akhilerm/add-tag-push-action
Add tag-push action to advanced usage section
2 parents 655d1f6 + 5b3f377 commit 95f9975

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ ___
3131
* [Secrets](docs/advanced/secrets.md)
3232
* [Isolated builders](docs/advanced/isolated-builders.md)
3333
* [Push to multi-registries](docs/advanced/push-multi-registries.md)
34+
* [Copy between registries](docs/advanced/copy-between-registries.md)
3435
* [Cache](docs/advanced/cache.md)
3536
* [Registry cache](docs/advanced/cache.md#registry-cache)
3637
* [GitHub cache](docs/advanced/cache.md#github-cache)
@@ -167,6 +168,7 @@ jobs:
167168
* [Secrets](docs/advanced/secrets.md)
168169
* [Isolated builders](docs/advanced/isolated-builders.md)
169170
* [Push to multi-registries](docs/advanced/push-multi-registries.md)
171+
* [Copy between registries](docs/advanced/copy-between-registries.md)
170172
* [Cache](docs/advanced/cache.md)
171173
* [Registry cache](docs/advanced/cache.md#registry-cache)
172174
* [GitHub cache](docs/advanced/cache.md#github-cache)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copy images between registries
2+
3+
Multi-platform images built using buildx can be copied from one registry to another without
4+
changing the image SHA using the [tag-push-action](https://github.com/akhilerm/tag-push-action).
5+
6+
The following workflow will first push the image to dockerhub, run some tests using the images
7+
and then push to quay and ghcr
8+
9+
```yaml
10+
name: ci
11+
12+
on:
13+
push:
14+
branches:
15+
- 'master'
16+
17+
jobs:
18+
docker:
19+
runs-on: ubuntu-latest
20+
steps:
21+
-
22+
name: Checkout
23+
uses: actions/checkout@v2
24+
-
25+
name: Set up QEMU
26+
uses: docker/setup-qemu-action@v1
27+
-
28+
name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v1
30+
- # quay and ghcr logins for pushing image after testing
31+
name: Login to Quay Registry
32+
uses: docker/login-action@v1
33+
with:
34+
registry: quay.io
35+
username: ${{ secrets.QUAY_USERNAME }}
36+
password: ${{ secrets.QUAY_TOKEN }}
37+
-
38+
name: Login to GitHub Container Registry
39+
uses: docker/login-action@v1
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.repository_owner }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
-
45+
name: Login to DockerHub
46+
uses: docker/login-action@v1
47+
with:
48+
username: ${{ secrets.DOCKERHUB_USERNAME }}
49+
password: ${{ secrets.DOCKERHUB_TOKEN }}
50+
-
51+
name: Build and push
52+
uses: docker/build-push-action@v2
53+
with:
54+
context: .
55+
platforms: linux/amd64,linux/arm64
56+
push: true
57+
tags: |
58+
user/app:latest
59+
user/app:1.0.0
60+
- # run tests using image from docker hub
61+
name: Run Tests
62+
run: make tests
63+
- # copy multiplatform image from dockerhub to quay and ghcr
64+
name: Push Image to multiple registries
65+
uses: akhilerm/tag-push-action@v1.0.0
66+
with:
67+
src: docker.io/user/app:1.0.0
68+
dst: |
69+
quay.io/user/app:latest
70+
quay.io/user/app:1.0.0
71+
ghcr.io/user/app:latest
72+
ghcr.io/user/app:1.0.0
73+
```

0 commit comments

Comments
 (0)