2021-05-12 12:23:06 +02:00
|
|
|
# Copy images between registries
|
|
|
|
|
|
|
|
Multi-platform images built using buildx can be copied from one registry to another without
|
|
|
|
changing the image SHA using the [tag-push-action](https://github.com/akhilerm/tag-push-action).
|
|
|
|
|
|
|
|
The following workflow will first push the image to dockerhub, run some tests using the images
|
|
|
|
and then push to quay and ghcr
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
name: ci
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2022-01-18 14:57:27 +01:00
|
|
|
- 'main'
|
2021-05-12 12:23:06 +02:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
docker:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
-
|
|
|
|
name: Set up QEMU
|
2022-05-05 19:24:32 +02:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2021-05-12 12:23:06 +02:00
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
2022-05-05 19:24:32 +02:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2021-05-12 12:23:06 +02:00
|
|
|
- # quay and ghcr logins for pushing image after testing
|
|
|
|
name: Login to Quay Registry
|
2022-05-05 19:24:32 +02:00
|
|
|
uses: docker/login-action@v2
|
2021-05-12 12:23:06 +02:00
|
|
|
with:
|
|
|
|
registry: quay.io
|
|
|
|
username: ${{ secrets.QUAY_USERNAME }}
|
|
|
|
password: ${{ secrets.QUAY_TOKEN }}
|
|
|
|
-
|
|
|
|
name: Login to GitHub Container Registry
|
2022-05-05 19:24:32 +02:00
|
|
|
uses: docker/login-action@v2
|
2021-05-12 12:23:06 +02:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
-
|
|
|
|
name: Login to DockerHub
|
2022-05-05 19:24:32 +02:00
|
|
|
uses: docker/login-action@v2
|
2021-05-12 12:23:06 +02:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
-
|
|
|
|
name: Build and push
|
2022-05-05 19:24:32 +02:00
|
|
|
uses: docker/build-push-action@v3
|
2021-05-12 12:23:06 +02:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
push: true
|
|
|
|
tags: |
|
|
|
|
user/app:latest
|
|
|
|
user/app:1.0.0
|
|
|
|
- # run tests using image from docker hub
|
|
|
|
name: Run Tests
|
|
|
|
run: make tests
|
|
|
|
- # copy multiplatform image from dockerhub to quay and ghcr
|
|
|
|
name: Push Image to multiple registries
|
2021-09-28 09:10:45 +02:00
|
|
|
uses: akhilerm/tag-push-action@v2.0.0
|
2021-05-12 12:23:06 +02:00
|
|
|
with:
|
|
|
|
src: docker.io/user/app:1.0.0
|
|
|
|
dst: |
|
|
|
|
quay.io/user/app:latest
|
|
|
|
quay.io/user/app:1.0.0
|
|
|
|
ghcr.io/user/app:latest
|
|
|
|
ghcr.io/user/app:1.0.0
|
|
|
|
```
|