GitHub Actions: tags/releases to GitHub Container Registry too

cache-manifests-tiers
Ricardo Pardini 2020-10-30 13:09:27 +01:00
parent eafedba51b
commit 427dd066bd
2 changed files with 18 additions and 11 deletions

View File

@ -43,7 +43,7 @@ jobs:
# due to the way manifests work, the gap between this and the complete push below # due to the way manifests work, the gap between this and the complete push below
# could result in pull failures or inconsistencies for arm64, such is life. # could result in pull failures or inconsistencies for arm64, such is life.
# further duplicated by building both release and debug builds # further duplicated by building both release and debug builds
- name: Build and push amd64 Release Docker Image to DockerHub - name: Build and push amd64 Release Docker Image to DockerHub/GitHub CR
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
build-args: | build-args: |
@ -58,7 +58,7 @@ jobs:
cache-from: type=local,src=/tmp/.buildx-cache/release cache-from: type=local,src=/tmp/.buildx-cache/release
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache/release cache-to: type=local,mode=max,dest=/tmp/.buildx-cache/release
- name: Build and push amd64 Debug Docker Image to DockerHub - name: Build and push amd64 Debug Docker Image to DockerHub/GitHub CR
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
build-args: | build-args: |

View File

@ -39,17 +39,24 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-buildxarch- ${{ runner.os }}-buildxarch-
- name: Login to DockerHub - name: Docker Login to DockerHub
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
username: ${{ secrets.DOCKER_HUB_USERNAME }} username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Docker Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_GITHUB_USERNAME }}
password: ${{ secrets.DOCKER_GITHUB_PAT }}
# the arm64 is of course much slower due to qemu, so build and push amd64 **first** # the arm64 is of course much slower due to qemu, so build and push amd64 **first**
# due to the way manifests work, the gap between this and the complete push below # due to the way manifests work, the gap between this and the complete push below
# could result in pull failures or inconsistencies for arm64, such is life. # could result in pull failures or inconsistencies for arm64, such is life.
# further duplicated by building both release and debug builds # further duplicated by building both release and debug builds
- name: Build and push amd64 Release Docker Image to DockerHub - name: Build and push amd64 Release Docker Image to DockerHub/GitHub CR
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
build-args: | build-args: |
@ -59,12 +66,12 @@ jobs:
context: . context: .
file: ./Dockerfile file: ./Dockerfile
platforms: linux/amd64 platforms: linux/amd64
tags: rpardini/docker-registry-proxy:${{ steps.get_version.outputs.version }} tags: rpardini/docker-registry-proxy:${{ steps.get_version.outputs.version }},ghcr.io/rpardini/docker-registry-proxy:${{ steps.get_version.outputs.version }}
push: true push: true
cache-from: type=local,src=/tmp/.buildx-cache/release cache-from: type=local,src=/tmp/.buildx-cache/release
# first run does not export the cache # first run does not export the cache
- name: Build and push amd64 Debug Docker Image to DockerHub - name: Build and push amd64 Debug Docker Image to DockerHub/GitHub CR
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
build-args: | build-args: |
@ -74,14 +81,14 @@ jobs:
context: . context: .
file: ./Dockerfile file: ./Dockerfile
platforms: linux/amd64 platforms: linux/amd64
tags: rpardini/docker-registry-proxy:${{ steps.get_version.outputs.version }}-debug tags: rpardini/docker-registry-proxy:${{ steps.get_version.outputs.version }}-debug,ghcr.io/rpardini/docker-registry-proxy:${{ steps.get_version.outputs.version }}-debug
push: true push: true
cache-from: type=local,src=/tmp/.buildx-cache/debug cache-from: type=local,src=/tmp/.buildx-cache/debug
# first run does not export the cache # first run does not export the cache
# Do it all again with both archs. the amd64 will be a huge cache hit # Do it all again with both archs. the amd64 will be a huge cache hit
# this will update the manifest have both arches # this will update the manifest have both arches
- name: Build and push multiarch Release Docker Image to DockerHub - name: Build and push multiarch Release Docker Image to DockerHub/GitHub CR
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
build-args: | build-args: |
@ -91,12 +98,12 @@ jobs:
context: . context: .
file: ./Dockerfile file: ./Dockerfile
platforms: linux/arm64,linux/amd64 platforms: linux/arm64,linux/amd64
tags: rpardini/docker-registry-proxy:${{ steps.get_version.outputs.version }} tags: rpardini/docker-registry-proxy:${{ steps.get_version.outputs.version }},ghcr.io/rpardini/docker-registry-proxy:${{ steps.get_version.outputs.version }}
push: true push: true
cache-from: type=local,src=/tmp/.buildx-cache/release cache-from: type=local,src=/tmp/.buildx-cache/release
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache/release cache-to: type=local,mode=max,dest=/tmp/.buildx-cache/release
- name: Build and push multiarch Debug Docker Image to DockerHub - name: Build and push multiarch Debug Docker Image to DockerHub/GitHub CR
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
build-args: | build-args: |
@ -106,7 +113,7 @@ jobs:
context: . context: .
file: ./Dockerfile file: ./Dockerfile
platforms: linux/arm64,linux/amd64 platforms: linux/arm64,linux/amd64
tags: rpardini/docker-registry-proxy:${{ steps.get_version.outputs.version }}-debug tags: rpardini/docker-registry-proxy:${{ steps.get_version.outputs.version }}-debug,ghcr.io/rpardini/docker-registry-proxy:${{ steps.get_version.outputs.version }}-debug
push: true push: true
cache-from: type=local,src=/tmp/.buildx-cache/debug cache-from: type=local,src=/tmp/.buildx-cache/debug
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache/debug cache-to: type=local,mode=max,dest=/tmp/.buildx-cache/debug